Closed
Description
test {
@setRuntimeSafety(false);
var self: []const u8 = "abcdef";
var index: usize = 0;
var left_index = (index << 1) + 1;
var right_index = left_index + 1;
var left = if (left_index < self.len) self[left_index] else null;
var right = if (right_index < self.len) self[right_index] else null;
std.debug.print("left {d} right {d}\n", .{ left_index < self.len, right_index < self.len });
std.debug.print("left {d} right {d}\n", .{ left, right });
}
The same binary produced by zig2 test a.zig -femit-bin=a
ran multiple times will sometimes print the correct result left 98 right 99
and on other times left null right null
. When compiled in a release mode it always produces the correct result, @setRuntimeSafety
does not work as the resulting AIR always has calls to panicOutOfBounds
.
This is blocking std.PriorityQueue
tests.