Michel Fortin wrote:
On 2010-11-05 23:27:28 -0400, Walter Bright <newshou...@digitalmars.com> said:

Michel Fortin wrote:
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.

Really? I'm doing two things in "(*arrayPtr)[66000-1]" in the above code:

1. Dereferencing a pointer to a the static array;
2. Accessing the last element within the bounds of the static array.

Which of these is disallowed in safe mode?

I think you should reread this example more attentively. It's no different than if you had put the static array as a member in a struct.


Looks like you're right.

Reply via email to