Pointers - Is it safe to point to invalid memory?

0xEAB desisma at heidel.beer
Sat Aug 16 23:45:26 UTC 2025


On Saturday, 16 August 2025 at 23:42:04 UTC, 0xEAB wrote:
> you can create a zero-length slice outside of the “range” of 
> the original slice.

int[] foo = [0, 1, 2];
int[] bar = foo[3 .. $]; // OK
int[] boo = foo[3 .. 4]; // Error: slice [3 .. 4] extends past 
source array of length 3




More information about the Digitalmars-d-learn mailing list