changeset 485:50f6e2337a6b

Default initialize temporary struct generated from struct literal. This makes sure padding is zeroed out.
author Christian Kamm <kamm incasoftware de>
date Sat, 09 Aug 2008 09:03:52 +0200
parents 1e96c742be5a
children a34078905d01
files gen/toir.cpp
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gen/toir.cpp	Thu Aug 07 18:59:23 2008 +0200
+++ b/gen/toir.cpp	Sat Aug 09 09:03:52 2008 +0200
@@ -2145,6 +2145,13 @@
 
     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;