Default initialize temporary struct generated from struct literal.

This makes sure padding is zeroed out.
This commit is contained in:
Christian Kamm
2008-08-09 09:03:52 +02:00
parent 6e78763b3f
commit b2d860374b

View File

@@ -2145,6 +2145,13 @@ DValue* StructLiteralExp::toElem(IRState* p)
LLValue* sptr = DtoAlloca(llt,"tmpstructliteral");
// default init the struct to take care of padding
// and unspecified members
TypeStruct* ts = (TypeStruct*)type;
assert(ts->sym);
DtoForceConstInitDsymbol(ts->sym);
assert(ts->sym->ir.irStruct->init);
DtoAggrCopy(sptr, ts->sym->ir.irStruct->init);
// num elements in literal
unsigned n = elements->dim;