Michel Fortin wrote:
On 2010-11-05 20:04:11 -0400, Walter Bright <[email protected]> said:

Michel Fortin wrote:
On 32-bit OS X, that limit is 4 KB.

That's good to know.

Well, you should already know. I posted this on the Phobos mailing list in August and you posted a reply. :-)

Yeah, well, my brain is full. In order to learn new facts, I must discard an equivalent number of existing ones. I've had to discard everything I ever learned about chemistry, for example.



And what happens if I dereference a null pointer to a static array of 65k elements and I try to read the last one?

Array index out of bounds.

There's nothing out of the array's bounds in this case. Here's what I meant:

    byte[66000]* arrayPtr = null;
    byte b = (*arrayPtr)[66000-1];

I'm in the array's bounds here, the problem is that I'm dereferencing a null pointer but the program will actually only read 65999 bytes further, outside of the 64 KB "safe" zone.

Should we limit static arrays to 64 KB too?

That's why pointer arithmetic (which is what this is) is disallowed in safe 
mode.

Reply via email to