diff --git a/src/ir.cpp b/src/ir.cpp index ccdd34f893868b9f70beffcbc225e4dc30c85f2c..e98f028e3114b9c18dd6fff297161db479aaa958 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -24564,7 +24564,11 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) return result_loc; - return instruction->result_loc_bit_cast->parent->gen_instruction; + if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { + return instruction->result_loc_bit_cast->parent->gen_instruction; + } + + return result_loc; } static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, diff --git a/test/stage1/behavior/bitcast.zig b/test/stage1/behavior/bitcast.zig index 394ade1a217d7456959a961c9e0ed8b731b894d1..92777e3d1285fda86b5b3196aa6c18d307bd773d 100644 --- a/test/stage1/behavior/bitcast.zig +++ b/test/stage1/behavior/bitcast.zig @@ -125,3 +125,9 @@ test "implicit cast to error union by returning" { S.entry(); comptime S.entry(); } + +// issue #3010: compiler segfault +test "bitcast literal [4]u8 param to u32" { + const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 }); + expect(ip == maxInt(u32)); +}