diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-03-16 18:42:01 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-18 11:10:45 -0400 |
| commit | 1479c28b496e7c1db134b51f23dd2eb934b123bb (patch) | |
| tree | 58c01e7e6308e50c20d352b7ce7106c1152641ef /src/codegen.cpp | |
| parent | 013ada1b59e50bbbab19acab0a79dae72133999a (diff) | |
| download | zig-1479c28b496e7c1db134b51f23dd2eb934b123bb.tar.gz zig-1479c28b496e7c1db134b51f23dd2eb934b123bb.zip | |
ir: Correct ABI size calculation for arrays
Zero-length array with a sentinel may not have zero size.
Closes #4749
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index dc6fe04cb4..75f3223250 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3584,7 +3584,9 @@ static bool value_is_all_undef(CodeGen *g, ZigValue *const_val) { } return true; } else if (const_val->type->id == ZigTypeIdArray) { - return value_is_all_undef_array(g, const_val, const_val->type->data.array.len); + const size_t full_len = const_val->type->data.array.len + + (const_val->type->data.array.sentinel != nullptr); + return value_is_all_undef_array(g, const_val, full_len); } else if (const_val->type->id == ZigTypeIdVector) { return value_is_all_undef_array(g, const_val, const_val->type->data.vector.len); } else { |
