Zig Version
0.9.0-dev.1945+efdb94486
Steps to Reproduce
Run this test file:
var l: u8 = 1;
var r: ?u8 = 2;
test {
const foo: u8 = 1;
if (l == foo) {} else {
_ = r == foo;
}
}
E.g. $ zig test snippet.zig. I ran it on Linux; I'm not sure if there will be differences between OSes.
I whittled this down as much as I could from how I encountered it, but I'm not sure it's minimal.
Expected Behavior
The test should compile and run.
Actual Behavior
The compilation stops part-way through and terminates with SIGSEV. I use fish, and this is the output:
fish: Job 1, 'zig test bug_repr.zig' terminated by signal SIGSEGV (Address boundary
error)
Running the command through lldb gives this output:
$ lldb zig test bug_repr.zig
(lldb) target create "zig"
Current executable set to 'zig' (x86_64).
(lldb) settings set -- target.run-args "test" "bug_repr.zig"
(lldb) run
Process 35455 launched: '/usr/bin/zig' (x86_64)
Semantic Analysis [1002/1405] Process 35455 stopped
* thread #1, name = 'zig', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
frame #0: 0x0000000007348340 zig`llvm::BasicBlock::getContext() const
zig`llvm::BasicBlock::getContext:
-> 0x7348340 <+0>: movq (%rdi), %rax
0x7348343 <+3>: movq (%rax), %rax
0x7348346 <+6>: retq
0x7348347: int3
(lldb) bt
* thread #1, name = 'zig', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
* frame #0: 0x0000000007348340 zig`llvm::BasicBlock::getContext() const
frame #1: 0x0000000007407309 zig`llvm::BranchInst::BranchInst(llvm::BasicBlock*, llvm::Instruction*) + 25
frame #2: 0x0000000007380060 zig`LLVMBuildBr + 48
frame #3: 0x00000000032d670f zig`ir_render(CodeGen*, ZigFn*) + 6239
frame #4: 0x00000000032cab8b zig`do_code_gen(CodeGen*) + 2171
frame #5: 0x00000000032c7eae zig`codegen_build_object(CodeGen*) + 3310
frame #6: 0x00000000032bff28 zig`zig_stage1_build_object + 2392
frame #7: 0x0000000002f96213 zig`Compilation.processOneJob + 78307
frame #8: 0x0000000002f7907c zig`Compilation.update + 4268
frame #9: 0x0000000002f39aaf zig`main.updateModule + 31
frame #10: 0x0000000002f0f185 zig`main.buildOutputType + 78757
frame #11: 0x0000000002ef0df4 zig`main + 2212
frame #12: 0x000000000762fd3a zig`libc_start_main_stage2 + 41
frame #13: 0x0000000002eef5b6 zig`_start + 22
Zig Version
0.9.0-dev.1945+efdb94486
Steps to Reproduce
Run this test file:
E.g.
$ zig test snippet.zig. I ran it on Linux; I'm not sure if there will be differences between OSes.I whittled this down as much as I could from how I encountered it, but I'm not sure it's minimal.
Expected Behavior
The test should compile and run.
Actual Behavior
The compilation stops part-way through and terminates with SIGSEV. I use fish, and this is the output:
Running the command through lldb gives this output: