Maximum array size

Dave Dave_member at pathlink.com
Wed Apr 26 02:31:44 PDT 2006


In article <e2m3ll$v0k$1 at digitaldaemon.com>, gassa at mail.ru says...
>
>Hi!
>
>What is the 16M limit on the array length for?
>Recently I needed more space but when I declared a ~25M array of ubytes I
>quickly ran into a compile error saying
>> file.d(5): index 25000000 overflow for static array
>
>An investigation got me to lines 1592-1593 of src/dmd/mtype.c stating
>> if (n2 >= 0x1000000)    // put a 'reasonable' limit on it
>>     goto Loverflow;
>with the above message printed at Loverflow.
>
>I wonder what's the 'reason' on that limit.
>
>Eventually, I didn't give up and, with a bit of disassembly, lifted the limit in
>the comparison to 768M (you know, there doesn't seem to be a way to just
>recompile the code, since it's incomplete). At first, everything looked fine: my
>program compiled and ran and the result of using that ~25M array was the same as
>in C (by the way, there were no such problems with dmc compiler). But later, I
>discovered that:
>1. Trying to allocate a bigger static array (say, ~100M) just hangs the compiler
>up;
>2. Trying to allocate even a ~25M array of bits (which should consume less than
>4M space) does the same - the compiler hangs up.
>Could anyone explain what's the problem?
>
>I'm new to D Programming Language. I discovered it only recently and decided to
>give it a try. Currently, I seem to like it's look and feel, although such
>undocumented misfeatures of dmd, the only compiler I know of, do present a bit
>of trouble.
>
>Thanks in advance,
>Ivan Kazmenko.

Why the need for such a large static array? Can't a dynamic array be used in
your code instead?





More information about the Digitalmars-d mailing list