Zig Version
0.13.0-dev.211+6a65561e3
Steps to Reproduce and Observed Behavior
Run the following code:
const std = @import("std");
pub const Foo = packed struct(u2) {
a: bool = undefined,
b: bool,
};
const foo = Foo{
.b = true,
};
pub fn main() void {
std.debug.print("{}\n", .{foo});
std.debug.print("{}\n", .{foo.b});
}
which prints
example.Foo{ .a = false, .b = false }
true
Notice how when we print foo, we get .b = false, but when we print foo.b we get true.
Expected Behavior
Both of them should print b as being true, but the first one doesn't.
A few things I've noticed:
- If you change the
undefined default value with false, then everything works as expected
- Pretty recent regression, works in zig 0.12.0
Zig Version
0.13.0-dev.211+6a65561e3
Steps to Reproduce and Observed Behavior
Run the following code:
which prints
Notice how when we print
foo, we get.b = false, but when we printfoo.bwe gettrue.Expected Behavior
Both of them should print
bas beingtrue, but the first one doesn't.A few things I've noticed:
undefineddefault value withfalse, then everything works as expected