comparison run/m/memory_management_07_A.d @ 1579:1802d6b67634

[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays <david@acz.org> 2007-11-12 http://d.puremagic.com/issues/show_bug.cgi?id=1666
author thomask
date Fri, 22 Feb 2008 07:54:04 +0000
parents
children
comparison
equal deleted inserted replaced
1578:10a4a6037695 1579:1802d6b67634
1 // $HeadURL$
2 // $Date$
3 // $Author$
4
5 // @author@ <david@acz.org>
6 // @date@ 2007-11-12
7 // @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1666
8 // @desc@ [Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
9
10 module dstress.run.m.memory_management_07_A;
11
12 int main(char[][] args){
13 ubyte x[];
14 size_t len = size_t.max - (size_t.max / 32);
15
16 try{
17 x.length = len;
18 }catch(Exception e){
19 // "out of memory" Exception
20 return 0;
21 }
22
23 // a LOT of memory (maybe someone cheated *g*)
24 if(len != x.length){
25 assert(0);
26 }
27
28 // try to defeat "smart" cheaters
29 size_t step = 4096 - args.length;
30 for(size_t i = 0; i < len; i += step){
31 x[i] = i & 0xFF;
32 }
33
34 step = 4096 - ((args[0].length / 1000 + 1) % 13);
35 for(size_t i = 0; i < len; i += step){
36 if((i & 0xFF) != x[i]){
37 assert(0);
38 }
39 }
40
41 return 0;
42 }