-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.miscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.
Milestone
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.
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.miscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.