https://issues.dlang.org/show_bug.cgi?id=20964
Stefan Koch <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #6 from Stefan Koch <[email protected]> --- To make this code example clearer: this compiles without complaints in non-@safe code and works. void main() { uint[3] arr = [1,2,3]; assert(foo(arr) == arr[0]); } uint foo(uint[3] m) { auto p = &m[0]; // pointing the first element p += 8; // pointing to an invalid address &m[9] p -= 11; // pointer to an invalid address &[m-2] p++; // after this statement pointing the valid address &m[-1] again return *++p; // *p should yield m[0]; } Because at ctfe we can actually check that the final position of the pointer the point of using it to access memory is in the range of the original memory block; I have no issues with allowing this. --
