// test.zig
export fn foo() void {
var x: bool = false;
const v = // : usize here fixes the problem
while (x) : ({}) { // for loop has the same problem
if (x) continue;
break @as(usize, 0);
} else unreachable;
}
> zig version
0.7.0+97c0e1cc4
> zig build-obj test.zig
Code Generation [247/468] std.mem.Allocator.reallocAdvancedWithRetAddr... broken LLVM module found:
Terminator found in the middle of a basic block!
label %WhileElse
This is a bug in the Zig compiler.
src\stage1.zig:168:5: 0x7ff6705c21cf in stage2_panic (zig.o)
@panic(ptr[0..len]);
^
src\stage1\util.cpp:20:0: 0x7ff6705772b0 in zig_panic (util.o)
stage2_panic("", 0);
src\stage1\codegen.cpp:8412:0: 0x7ff67044ca28 in do_code_gen (codegen.o)
if (LLVMVerifyModule(g->module, LLVMReturnStatusAction, &error)) {
src\stage1\codegen.cpp:9555:0: 0x7ff67044951f in codegen_build_object (codegen.o)
{
src\stage1\stage1.cpp:127:0: 0x7ff67057117c in zig_stage1_build_object
(stage1.o)
codegen_build_object(g);
src\stage1.zig:140:32: 0x7ff6708d6556 in Module::Module.build_object (zig.o)
zig_stage1_build_object(mod);
^
src\Compilation.zig:3003:31: 0x7ff6707229af in Compilation.updateStage1Module (zig.o)
// We need to save the inferred link libs to the cache, otherwise if we get a cache hit
^
src\Compilation.zig:1533:36: 0x7ff6706ddb53 in Compilation.performAllTheWork (zig.o)
self.updateStage1Module(main_progress_node) catch |err| {
^
src\Compilation.zig:1227:31: 0x7ff6706d7a58 in Compilation.update (zig.o)
try self.performAllTheWork();
^
src\main.zig:1918:20: 0x7ff670685f57 in main.updateModule (zig.o)
}
^
src\main.zig:1780:17: 0x7ff6705d764d in main.buildOutputType (zig.o)
}
^
src\main.zig:164:31: 0x7ff6705c1291 in main.mainArgs (zig.o)
return buildOutputType(gpa, arena, args, .{ .build = .Obj });
^
src\stage1.zig:45:24: 0x7ff6705c0e05 in main (zig.o)
stage2.mainArgs(gpa, arena, args) catch unreachable;
^