Zig Version
0.16.0-dev.235+377a8b2a3
Steps to Reproduce and Observed Behavior
pub fn main() void {
var cond = false;
_ = &cond;
const num: f32 = if (cond) 100 else 200;
var a = f();
_ = &a;
std.debug.print("{}\n", .{num});
}
pub fn f() callconv(.c) A {
return .{};
}
pub const A = extern struct {
x: f32 = 0,
y: f32 = 0,
z: f32 = 0,
};
On Fedora linux x86_64, running this snippet with zig run src/main.zig outputs 0
Running with zig run src/main.zig -fllvm outputs 200
Notes:
Inserting a print before f is called gives a correct output of 200 twice.
Replacing
const num: f32 = if (cond) 100 else 200;
with
var num: f32 = 200;
if (cond) num = 100;
also gives the correct output of 200.
Expected Behavior
Expected an output of 200 with the original snippet
Zig Version
0.16.0-dev.235+377a8b2a3
Steps to Reproduce and Observed Behavior
On Fedora linux x86_64, running this snippet with
zig run src/main.zigoutputs0Running with
zig run src/main.zig -fllvmoutputs200Notes:
Inserting a
printbeforefis called gives a correct output of200twice.Replacing
with
also gives the correct output of
200.Expected Behavior
Expected an output of
200with the original snippet