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

BCS ao at pathlink.com
Tue Oct 2 14:51:46 PDT 2007


Reply to Vladimir,

> On Tue, 02 Oct 2007 22:30:25 +0300, BCS <ao at pathlink.com> wrote:
> 
> 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.
> 

Unless I'm smoking something, the code to access any array will look the 
same regardless of where the array is.

Get base aggress
compute offset
add them
*dereference* that address

the only difference is how the base address is found. with static arrays 
it can be coded as a part of the opcode (I think), with general arrays, it 
is loaded from a variable, and with an array in the stack frame, it is pulled 
from the  frame pointer*. But in all cases, their is still a dereference.


* BTW, accessing a local variable also does a dereference, just where the 
offset is known at compile time.





More information about the Digitalmars-d mailing list