aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-03-16 18:42:01 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-03-18 11:10:45 -0400
commit1479c28b496e7c1db134b51f23dd2eb934b123bb (patch)
tree58c01e7e6308e50c20d352b7ce7106c1152641ef /src/codegen.cpp
parent013ada1b59e50bbbab19acab0a79dae72133999a (diff)
downloadzig-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.cpp4
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 {