Maximum array size

gassa at mail.ru gassa at mail.ru
Tue Apr 25 14:17:41 PDT 2006


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.



More information about the Digitalmars-d mailing list