Re: Static array size limit

2011-04-04 Thread simendsjo
And it seems also Walter is meaning mebibytes: enum size = (16*1024*1024)/int.sizeof; static assert(!__traits(compiles, int[size])); static assert(__traits(compiles, int[size-1]));

Re: Static array size limit

2011-04-04 Thread Jonathan M Davis
On 2011-04-04 06:37, Steven Schveighoffer wrote: > On Sat, 02 Apr 2011 10:45:51 -0400, bearophile > > wrote: > > simendsjo: > >> http://digitalmars.com/d/2.0/arrays.html says static arrays are > >> limited to 16mb, but I can only allocate 1mb. > >> My fault, or bug? > > > > It accepts 4_000_000

Re: Static array size limit

2011-04-04 Thread Steven Schveighoffer
On Mon, 04 Apr 2011 12:43:03 -0400, bearophile wrote: Steven Schveighoffer: That would be 16 MiB. http://en.wikipedia.org/wiki/Mebibyte Then I think 16 MiB are more useful than 16_000_000 bytes. Seems arbitrary to me. I'm sure some people feel 32MB would be more useful. -Steve

Re: Static array size limit

2011-04-04 Thread bearophile
Steven Schveighoffer: > That would be 16 MiB. > > http://en.wikipedia.org/wiki/Mebibyte Then I think 16 MiB are more useful than 16_000_000 bytes. Bye, bearophile

Re: Static array size limit

2011-04-04 Thread Steven Schveighoffer
On Sat, 02 Apr 2011 10:45:51 -0400, bearophile wrote: simendsjo: http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't k

Re: Static array size limit

2011-04-02 Thread bearophile
simendsjo: > The main problem is that it gives a Stack Overflow already at 250_001 I meant with the array as a global variable. The stack on Windows can be set very large too, with -L/STACK:1000 Bye, bearophile

Re: Static array size limit

2011-04-02 Thread simendsjo
On 02.04.2011 16:45, bearophile wrote: simendsjo: http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't know why it's designe

Re: Static array size limit

2011-04-02 Thread bearophile
simendsjo: > http://digitalmars.com/d/2.0/arrays.html says static arrays are > limited to 16mb, but I can only allocate 1mb. > My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304 ints. I don't know why it's designed this way... I'd like 4_194_304 ints

Re: Static array size limit

2011-04-02 Thread simendsjo
I think you missed my "/int.sizeof" at the end. enum size = (16*1024*1024)/int.sizeof; int[size] a; // "Error index overflow for static" as expected int[size-1] b; // stack overflow int[250_001] c; // stack overflow int[250_000] d; // ok

Re: Static array size limit

2011-04-02 Thread Jonathan M Davis
On 2011-04-02 06:21, simendsjo wrote: > http://digitalmars.com/d/2.0/arrays.html says static arrays are > limited to 16mb, but I can only allocate 1mb. > My fault, or bug? > > enum size = (16 * 1024 * 1024) / int.sizeof; > //int[size] a; // Error: index 4194304 overflow for static >

Re: Static array size limit

2011-04-02 Thread simendsjo
This is using dmd 2.052 on windows by the way.

Static array size limit

2011-04-02 Thread simendsjo
http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? enum size = (16 * 1024 * 1024) / int.sizeof; //int[size] a; // Error: index 4194304 overflow for static array enum size2 = (16 * 1000 * 1000) /