zig
zig copied to clipboard
codegen.zig: Lowering pointer resulted in unreachable code
Zig Version
0.14.0-dev.208+854e86c56
Steps to Reproduce and Observed Behavior
Clone the following repo: s2s run zig test with the file s2s.zig
The output result from it is the following:
thread 19966 panic: reached unreachable code
/home/dan/zig/zig/src/codegen.zig:680:56: 0x1d177ee in lowerPtr (zig)
.arr_elem, .comptime_field, .comptime_alloc => unreachable,
^
/home/dan/zig/zig/src/codegen.zig:320:37: 0x1b00ee4 in generateSymbol (zig)
.ptr => switch (try lowerPtr(bin_file, pt, src_loc, val.toIntern(), code, debug_output, reloc_info, 0)) {
^
/home/dan/zig/zig/src/codegen.zig:325:39: 0x1b01082 in generateSymbol (zig)
switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.ptr), code, debug_output, reloc_info)) {
^
/home/dan/zig/zig/src/link/Elf/ZigObject.zig:1338:43: 0x238671c in lowerConst (zig)
const res = try codegen.generateSymbol(&elf_file.base, pt, src_loc, val, &code_buffer, .{
^
/home/dan/zig/zig/src/link/Elf/ZigObject.zig:1294:50: 0x37b6b5f in lowerUnnamedConst (zig)
const sym_index = switch (try self.lowerConst(
^
/home/dan/zig/zig/src/link/Elf.zig:3008:51: 0x37b6fb8 in lowerUnnamedConst (zig)
return self.zigObjectPtr().?.lowerUnnamedConst(self, pt, val, decl_index);
^
/home/dan/zig/zig/src/link.zig:375:87: 0x363b73f in lowerUnnamedConst (zig)
return @as(*t.Type(), @fieldParentPtr("base", base)).lowerUnnamedConst(pt, val, decl_index);
^
/home/dan/zig/zig/src/codegen.zig:948:49: 0x3359a81 in genUnnamedConst (zig)
const local_sym_index = lf.lowerUnnamedConst(pt, val, owner_decl_index) catch |err| {
^
/home/dan/zig/zig/src/codegen.zig:1104:27: 0x30b7027 in genTypedValue (zig)
return genUnnamedConst(lf, pt, src_loc, val, owner_decl_index);
^anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:18807:45: 0x2e0143c in genTypedValue (zig)
return switch (try codegen.genTypedValue(self.bin_file, pt, self.src_loc, val, self.owner.getDecl(pt.zcu))) {
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:18740:53: 0x2dff68f in resolveInst (zig)
const const_mcv = try self.genTypedValue(Value.fromInterned(ip_index));
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:5630:43: 0x3595c17 in genSliceElemPtr (zig)
const slice_mcv = try self.resolveInst(lhs);
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:5674:50: 0x35968df in airSliceElemVal (zig)
const elem_ptr = try self.genSliceElemPtr(bin_op.lhs, bin_op.rhs);
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2139:61: 0x3258d5b in genBody (zig)
.slice_elem_val => try self.airSliceElemVal(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13110:21: 0x352a6c0 in airCondBr (zig)
try self.genBody(then_body);
^sive__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2052:51: 0x325743d in genBody (zig)
.cond_br => try self.airCondBr(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13500:21: 0x3527478 in lowerBlock (zig)
try self.genBody(body);
^sive__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13487:24: 0x3527b62 in airBlock (zig)
try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
^e__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2045:50: 0x32571f6 in genBody (zig)
.block => try self.airBlock(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13472:21: 0x353b3d7 in airLoop (zig)
try self.genBody(body);
^sive__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2067:49: 0x3257938 in genBody (zig)
.loop => try self.airLoop(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13500:21: 0x3527478 in lowerBlock (zig)
try self.genBody(body);
^sive__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13487:24: 0x3527b62 in airBlock (zig)
try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
^e__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2045:50: 0x32571f6 in genBody (zig)
.block => try self.airBlock(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13500:21: 0x3527478 in lowerBlock (zig)
try self.genBody(body);
^sive__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:13487:24: 0x3527b62 in airBlock (zig)
try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
^e__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:2045:50: 0x32571f6 in genBody (zig)
.block => try self.airBlock(inst),
^
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:1825:25: 0x2f48114 in gen (zig)
try self.genBody(self.air.getMainBody());
^__anon_6665
/home/dan/zig/zig/src/arch/x86_64/CodeGen.zig:914:17: 0x2ce5256 in generate (zig)
function.gen() catch |err| switch (err) {
^ecursive__anon_6665
/home/dan/zig/zig/src/codegen.zig:71:70: 0x29b0671 in generateFunction (zig)
.x86_64 => return @import("arch/x86_64/CodeGen.zig").generate(lf, pt, src_loc, func_index, air, liveness, code, debug_output),
^
/home/dan/zig/zig/src/link/Elf/ZigObject.zig:1082:45: 0x29afb8b in updateFunc (zig)
const res = try codegen.generateFunction(
^
/home/dan/zig/zig/src/link/Elf.zig:2992:44: 0x29b0a6e in updateFunc (zig)
return self.zigObjectPtr().?.updateFunc(self, pt, func_index, air, liveness);
^
/home/dan/zig/zig/src/link.zig:422:82: 0x25fc940 in updateFunc (zig)
return @as(*tag.Type(), @fieldParentPtr("base", base)).updateFunc(pt, func_index, air, liveness);
^
/home/dan/zig/zig/src/Zcu/PerThread.zig:742:22: 0x2238cce in linkerUpdateFunc (zig)
lf.updateFunc(pt, func_index, air, liveness) catch |err| switch (err) {
^ive__anon_6665
/home/dan/zig/zig/src/Compilation.zig:3863:36: 0x1e8d5b3 in processOneCodegenJob (zig)
try pt.linkerUpdateFunc(func.func, func.air);
^
/home/dan/zig/zig/src/Compilation.zig:3816:36: 0x1e8d3a3 in queueCodegenJob (zig)
return processOneCodegenJob(tid, comp, codegen_job);
^
/home/dan/zig/zig/src/Compilation.zig:3518:37: 0x1cc1210 in processOneJob (zig)
try comp.queueCodegenJob(tid, .{ .func = .{
^
/home/dan/zig/zig/src/Compilation.zig:3465:30: 0x1aa5ecf in performAllTheWorkInner (zig)
try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, work_item, main_progress_node);
^n_6665
/home/dan/zig/zig/src/Compilation.zig:3345:36: 0x196d120 in performAllTheWork (zig)
try comp.performAllTheWorkInner(main_progress_node);
^
/home/dan/zig/zig/src/Compilation.zig:2169:31: 0x196a235 in update (zig)
try comp.performAllTheWork(main_progress_node);
^_6665
/home/dan/zig/zig/src/main.zig:4422:20: 0x1999210 in updateModule (zig)
try comp.update(prog_node);
^
/home/dan/zig/zig/src/main.zig:3439:21: 0x19cbc43 in buildOutputType (zig)
updateModule(comp, color, root_prog_node) catch |err| switch (err) {
^
/home/dan/zig/zig/src/main.zig:269:31: 0x185de5a in mainArgs (zig)
return buildOutputType(gpa, arena, args, .zig_test);
^
/home/dan/zig/zig/src/main.zig:209:20: 0x185997a in main (zig)
return mainArgs(gpa, arena, args);
^
/home/dan/zig/zig/lib/std/start.zig:515:37: 0x1859075 in posixCallMainAndExit (zig)
const result = root.main() catch |err| {
^
/home/dan/zig/zig/lib/std/start.zig:258:5: 0x1858b91 in _start (zig)
asm volatile (switch (native_arch) {
^
???:?:?: 0x5 in ??? (???)
Unwind information for `???:0x5` was not available, trace may be incomplete
Expected Behavior
To run the test correctly
repo head is a75226f6c9e968456f9c831c8fffa39c44e61358 at time of writing