From b2d860374bed6ed1e6dca91b051de2e0ec71d235 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 9 Aug 2008 09:03:52 +0200 Subject: [PATCH] Default initialize temporary struct generated from struct literal. This makes sure padding is zeroed out. --- gen/toir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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;