Correctly zero out real padding in struct literals.

Fixes the std.variant unit tests on x86_64.
This commit is contained in:
David Nadlinger
2012-11-10 20:11:10 +01:00
parent ab94a6d60c
commit 5944e9cc51

View File

@@ -2991,6 +2991,17 @@ DValue* StructLiteralExp::toElem(IRState* p)
// store the initializer there
DtoAssign(loc, &field, val, TOKconstruct);
// Also zero out padding bytes counted as being part of the type in DMD
// but not in LLVM; e.g. real/x86_fp80.
int implicitPadding =
vd->type->size() - gDataLayout->getTypeStoreSize(DtoType(vd->type));
assert(implicitPadding >= 0);
if (implicitPadding > 0)
{
Logger::println("zeroing %d padding bytes", implicitPadding);
voidptr = write_zeroes(voidptr, offset - implicitPadding, offset);
}
#if DMDV2
Type *tb = vd->type->toBasetype();
if (tb->ty == Tstruct)