Static arrays inside struct and class - bug?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 1 10:29:53 PDT 2015
On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote:
> I wonder if the followings are compiler bugs:
No, it is by design, the idea is to keep static arrays smallish
so null references will be caught by the processor. (An overly
large static array could allow indexing it through a null pointer
to potentially reach another object.)
The easiest workaround is to just dynamically allocate such huge
arrays:
byte[] arr = new byte[](1024*1024*16);
ReadProcessMemory(Proc, 0xdeadbeef, arr.ptr, arr.length, null);
The arr.ptr and arr.length are the key arguments there.
More information about the Digitalmars-d-learn
mailing list