From 24deb1a7fe955202335ed7540fa20a43ae6eca36 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Tue, 6 Aug 2019 12:24:52 -0400 Subject: [PATCH] fix @bitCast segfault with literal array param closes #3010 --- src/ir.cpp | 2 +- test/stage1/behavior/bitcast.zig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ir.cpp b/src/ir.cpp index ccdd34f89..a018477e0 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -24561,7 +24561,7 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true); - if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) + 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; diff --git a/test/stage1/behavior/bitcast.zig b/test/stage1/behavior/bitcast.zig index 394ade1a2..a8d90b6ae 100644 --- a/test/stage1/behavior/bitcast.zig +++ b/test/stage1/behavior/bitcast.zig @@ -125,3 +125,8 @@ 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 }); +}