Union is not properly zero-initialized #1194

This commit is contained in:
Christoffer Lerno
2024-05-16 11:28:04 +02:00
parent e36c696624
commit 094c105464
6 changed files with 39 additions and 4 deletions

View File

@@ -2124,14 +2124,12 @@ static inline void llvm_emit_initialize_reference_designated(GenContext *c, BEVa
llvm_emit_initialize_reference_designated_bitstruct(c, ref, type->decl, elements);
return;
}
// Getting ready to initialize, get the real type.
Type *real_type = type_lowering(ref->type);
// Make sure we have an address.
llvm_value_addr(c, ref);
// Clear the memory if not union.
if (real_type->type_kind != TYPE_UNION) llvm_store_zero(c, ref);
// Clear the memory
llvm_store_zero(c, ref);
// Now walk through the elements.
VECEACH(elements, i)