zig icon indicating copy to clipboard operation
zig copied to clipboard

segfault `bitCast`ing arrays of comptime only types

Open xdBronch opened this issue 1 year ago • 1 comments

Zig Version

0.12.0-dev.3419+a2651cbc8

Steps to Reproduce and Observed Behavior

test {
    _ = @as([1]u32, @bitCast([_]comptime_int{0}));
}

this segfaults the compiler, it seems like any comptime only type causes this not just comptime_int

Expected Behavior

compile error

xdBronch avatar Mar 23 '24 07:03 xdBronch

happens because we run bitSize on the array, but never rule out a comptime_int array. Same thing should happen if [1]comptime_int as the destination size.

Rexicon226 avatar Mar 23 '24 07:03 Rexicon226