Skip to content

Commit 5004c76

Browse files
authored
Correct a mistaken range violation (#3741)
"d2 is unsafe because it goes beyond a's bounds." is incorrect, because slice "0..3" is non-inclusive, meaning that the slice is actually valid. (a.ptr[0..3] == a[0..$]) This is probably just a minor oversight about the range's end value being non-inclusive.
1 parent 6465a19 commit 5004c76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spec/function.dd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,8 +4011,8 @@ $(H3 $(LNAME2 safe-values, Safe Values))
40114011
bool b = true; /* b is initialized safe */
40124012
*(cast(ubyte*) &b) = 0xAA; /* b is now unsafe because it's not 0 or 1 */
40134013
int[3] a;
4014-
int[] d1 = a[0 .. 2]; /* d1 is safe. */
4015-
int[] d2 = a.ptr[0 .. 3]; /* d2 is unsafe because it goes beyond a's
4014+
int[] d1 = a[0 .. 3]; /* d1 is safe. */
4015+
int[] d2 = a.ptr[0 .. 4]; /* d2 is unsafe because it goes beyond a's
40164016
bounds. */
40174017
int*[] d3 = [cast(int*) 0xDEADBEEF]; /* d3 is unsafe because the
40184018
element is unsafe. */

0 commit comments

Comments
 (0)