Merge branch 'mikdusan-issue.3010'

closes #3022
closes #3010

thanks @mikdusan
This commit is contained in:
Andrew Kelley 2019-08-19 17:36:26 -04:00
commit 07c5e90601
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 11 additions and 1 deletions

View File

@ -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,

View File

@ -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));
}