diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-25 19:53:29 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-25 19:54:20 -0400 |
| commit | 4d8269f69f530fe251e3132a95285c0af9d3aaab (patch) | |
| tree | 9c00a12ea4176c2d2945a425825dffb0d7bc5c76 /src/ir.cpp | |
| parent | 754f7809e38d5d44da9d63241af310e6c0bee730 (diff) | |
| download | zig-4d8269f69f530fe251e3132a95285c0af9d3aaab.tar.gz zig-4d8269f69f530fe251e3132a95285c0af9d3aaab.zip | |
fix some casts on const data causing segfault
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 38c16b9a4e..f88612a049 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7330,7 +7330,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, case CastOpResizeSlice: case CastOpBytesToSlice: // can't do it - break; + zig_unreachable(); case CastOpIntToFloat: { assert(new_type->id == TypeTableEntryIdFloat); @@ -7366,7 +7366,9 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type, CastOp cast_op, bool need_alloca) { - if (value->value.special != ConstValSpecialRuntime) { + if (value->value.special != ConstValSpecialRuntime && + cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice) + { IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type); eval_const_expr_implicit_cast(cast_op, &value->value, value->value.type, @@ -8166,7 +8168,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst } } - // expliict cast from &const [N]T to []const T + // explicit cast from &const [N]T to []const T if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.is_const && |
