Maybe related to #3956.
The following code will cause the compiler to generate broken LLVM code on stage 1, master (e6a812c82):
const Data = struct {
data: [][]const u8,
pub fn init(d: [4]u8) Data {
return Data {
.data = d[0..3],
};
}
};
pub fn main() void {
var data = Data.init([4]u8{1, 2, 3, 4});
_ = data;
}
It exits with the following error:
broken LLVM module found: Stored value type does not match pointer operand type!
store i8* %4, %"[]u8"** %3, !dbg !12057
%"[]u8"*
This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
It does not appear when the indirection through init is taken away.
Reports error correctly on 68dbba212dd7393c90ab0e914dedeac975fa0224.
./test.zig:6:22: error: expected type '[][]const u8', found '[]const u8'
.data = d[0..3],
^
Most helpful comment
Reports error correctly on 68dbba212dd7393c90ab0e914dedeac975fa0224.