zig
zig copied to clipboard
ICE involving empty slice of anonymous struct type
Zig Version
0.14.0-dev.944+0e99f517f
Steps to Reproduce and Observed Behavior
The compiler segfaults on the following code:
export fn f() void {
// Does not work (but works if moved to after the below call):
try g(&.{});
// Works:
try g(&.{.{.{}}});
}
fn g(x: []const struct { S }) !void {
h(x);
}
fn h(_: []const struct { S }) void {}
pub const S = packed struct {};
https://godbolt.org/z/hTv94zaxo
Only when an empty slice is passed to g(), and the other conditions seem really specific. E.g. all of the following avoid the issue:
- returning
voidfromg() - making
Snon-packed - giving the anonymous
struct { S }a name
Expected Behavior
Compiles successfully