Zig Version
0.14.0-dev.3357+c44f4501e
Steps to Reproduce and Observed Behavior
It seems printing a union with at least 2 void fields results in unexpected errors. To reproduce:
const std = @import("std");
const Union = extern struct {
data: extern union {
first: void,
second: void,
},
};
pub fn main() !void {
const a = Union{
.data = .{
.first = {},
},
};
std.debug.print("{}\n", .{a});
}
This creates regular unexpected error output. However, you can get a fancy LLVM one too if you also provide an enum with explicit tag type:
const std = @import("std");
const EnumAndUnion = extern struct {
enumeration: enum(u8) { first, second },
data: extern union {
first: void,
second: void,
},
};
pub fn main() !void {
const a = EnumAndUnion{
.enumeration = .first,
.data = .{
.first = {},
},
};
std.debug.print("{}\n", .{a});
}
run
└─ run repro
└─ install
└─ install repro
└─ zig build-exe repro Debug native failure
error: error: Invalid cast (Producer: 'zig 0.14.0' Reader: 'LLVM 19.1.7')
Expected Behavior
It should print out correctly.
Zig Version
0.14.0-dev.3357+c44f4501e
Steps to Reproduce and Observed Behavior
It seems printing a union with at least 2 void fields results in unexpected errors. To reproduce:
This creates regular unexpected error output. However, you can get a fancy LLVM one too if you also provide an enum with explicit tag type:
run └─ run repro └─ install └─ install repro └─ zig build-exe repro Debug native failure error: error: Invalid cast (Producer: 'zig 0.14.0' Reader: 'LLVM 19.1.7')Expected Behavior
It should print out correctly.