-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
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
Zig Version
0.11.0-dev.6417+0bb178bbb
Steps to Reproduce and Observed Behavior
const std = @import("std");
const debug = std.debug;
pub fn main() void {
var a: *isize = blk: for (0..10) |_| {
break :blk;
};
debug.print("a: {}\n", .{a});
var b: *isize = blk: while (true) {
break :blk;
};
debug.print("b: {}\n", .{b});
}$ zig run main.ziga: isize@0
b: isize@7ffc30760750
NOTE: the output depends on the order of statements.
I got a consistent output when moving the b variable definition before a:
b: isize@0
a: isize@20
Expected Behavior
The compiler should report an error instead of causing an undefined behavior.
NOTE: I used a pointer variable to check if the value was the same as when using undefined.
squeek502 and likern
Metadata
Metadata
Assignees
Labels
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.