authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-08-06 12:24:52-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-19 17:24:14-04:00
log24deb1a7fe955202335ed7540fa20a43ae6eca36
tree0bac693e5ec127f7422bfce0829ef36c47490b67
parentefc2237e5a545fac94ecc9c9757d202bda322abd
signaturelock-open Commit is signed but in an unrecognized format.

fix @bitCast segfault with literal array param

closes #3010

2 files changed, 6 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
......@@ -24561,7 +24561,7 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst
2456124561
2456224562 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,
2456324563 &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true);
24564 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
24564 if (result_loc != nullptr && !(type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
2456524565 return result_loc;
2456624566
2456724567 return instruction->result_loc_bit_cast->parent->gen_instruction;
test/stage1/behavior/bitcast.zig+5
......@@ -125,3 +125,8 @@ test "implicit cast to error union by returning" {
125125 S.entry();
126126 comptime S.entry();
127127}
128
129// issue #3010: compiler segfault
130test "bitcast literal [4]u8 param to u32" {
131 const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 });
132}