"The total size of a static array cannot exceed 16Mb."

Vladimir Panteleev thecybershadow at gmail.com
Tue Oct 2 14:36:54 PDT 2007


On Tue, 02 Oct 2007 22:30:25 +0300, BCS <ao at pathlink.com> wrote:

> Sorry, no can do. Even with stack based static arrays there is a single dereference.
> An array access always does a dereference. (might you be thinking about indirects?)

If you're talking about the current situation in D with huge arrays, then it's so (and those don't fit in the stack anyway).
If not, well, it's certainly very possible if you just declare the array in the data segment (or with "static" anywhere else). Then, like I said earlier, "its address and the address of every of its elements is predetermined at compile time" - so "a static array placed in the data segment requires only arithmetics to access" ((base address+offset into element) + index*element size).

OPTLINK's limitation is around 16 MB of data for the data segment. This also includes initializations for structs, so you can't even have struct types with the gross size of more than 16 MB.

Other languages certainly would allow it, and I'm sure that if I would use a hex-edited dmd.exe with another linker - had I known a better DMD-compatible one - everything would work.

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list