diff options
| author | xackus <14938807+xackus@users.noreply.github.com> | 2020-04-23 03:06:41 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-04-23 12:45:32 -0400 |
| commit | a9eb4a6740e0bb00e1984de3768a7de6001c25dd (patch) | |
| tree | 5677ec8acfae34ec61eb74d775dc4289193c3224 /src/codegen.cpp | |
| parent | e6428f94013132b6a6284b053afb36d35af63c59 (diff) | |
| download | zig-a9eb4a6740e0bb00e1984de3768a7de6001c25dd.tar.gz zig-a9eb4a6740e0bb00e1984de3768a7de6001c25dd.zip | |
stage1: fix crash on accessing an array of size zero with runtime index
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 87881ccaf3..7d3e008a22 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3869,6 +3869,9 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutableGen *executable, assert(array_type->data.pointer.child_type->id == ZigTypeIdArray); array_type = array_type->data.pointer.child_type; } + + assert(array_type->data.array.len != 0 || array_type->data.array.sentinel != nullptr); + if (safety_check_on) { uint64_t extra_len_from_sentinel = (array_type->data.array.sentinel != nullptr) ? 1 : 0; uint64_t full_len = array_type->data.array.len + extra_len_from_sentinel; |
