ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.85k stars 2.55k forks source link

Crash initializing a union #21462

Closed wooster0 closed 1 month ago

wooster0 commented 1 month ago

Zig Version

0.14.0-dev.1588+2111f4c38

Steps to Reproduce and Observed Behavior

var a: union { b: u32 } = undefined;
export fn x() void {
    a = .{ .b = 0 };
}
$ zig build-obj x.zig
Trace/breakpoint trap

Expected Behavior

Successful compilation

wooster0 commented 1 month ago

Doesn't seem to happen if the union is packed or extern

wooster0 commented 1 month ago

This has to be a regression

Vexu commented 1 month ago

Duplicate of #19832