zig icon indicating copy to clipboard operation
zig copied to clipboard

compiler segmentation fault when mismatched declared array size to actual values

Open Pyrolistical opened this issue 3 years ago • 2 comments

Zig Version

0.10.0-dev.4253+fa9327ac0

Steps to Reproduce

  1. Given this file crash.zig
pub fn main() !void {
    const x: [2]i8 = .{0};
    _ = x;
}
  1. Run the command zig build-exe crash.zig

Expected Behavior

A compiler error: expected 2 array elements; found 1

Actual Behavior

segmentation fault

Pyrolistical avatar Oct 10 '22 04:10 Pyrolistical

Workaround for now is simply to write const x = [2]i8 {0};

Pyrolistical avatar Oct 10 '22 04:10 Pyrolistical

Also crashes when vec size is mismatched.

pub fn main() void {
    const foo: @Vector(3, u8) = .{ 0, 1 };
    _ = foo;
}

Still an issue on 0.11.0-dev.18+81c27677d

Pyrolistical avatar Nov 02 '22 20:11 Pyrolistical