diff --git a/gen/toir.cpp b/gen/toir.cpp index 8b3e7207..c1bcf2b9 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -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;