ir: Correct ABI size calculation for arrays

Zero-length array with a sentinel may not have zero size.

Closes #4749
This commit is contained in:
LemonBoy
2020-03-16 18:42:01 +01:00
committed by Andrew Kelley
parent 013ada1b59
commit 1479c28b49
3 changed files with 30 additions and 11 deletions

View File

@@ -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 {