diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-11-26 23:07:47 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-11-27 14:33:26 -0800 |
| commit | f91df39ad2a54bc5367ba562ca703e564dd4a38d (patch) | |
| tree | 490b5ee62acd2c0ba3708510f4cda30d6efab020 /src | |
| parent | 3bc1c719bd632e6baccb574bf75cb93f0bdef08f (diff) | |
| download | zig-f91df39ad2a54bc5367ba562ca703e564dd4a38d.tar.gz zig-f91df39ad2a54bc5367ba562ca703e564dd4a38d.zip | |
stage1: Fix crash in *[N]T to []T conversion with zst
Prevent the crash by not making the codegen try to access the
non-existing ptr field in the slice.
Closes #6951
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage1/codegen.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index 6a02f2912b..d308522943 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -3343,7 +3343,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen LLVMValueRef expr_val = ir_llvm_value(g, instruction->operand); LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, expr_val, indices, 2, ""); gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); - } else if (ir_want_runtime_safety(g, &instruction->base)) { + } else if (ir_want_runtime_safety(g, &instruction->base) && ptr_index != SIZE_MAX) { LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, result_loc, ptr_index, ""); gen_undef_init(g, slice_ptr_type, slice_ptr_type, ptr_field_ptr); } |
