From d128210f23764b266468fa059bfffa945f2adacf Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sun, 2 Jan 2011 17:42:59 +0300 Subject: [PATCH] Fixed initialization of a struct with an array from another struct --- gen/structs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gen/structs.cpp b/gen/structs.cpp index 8429664d..505bce87 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -280,6 +280,13 @@ std::vector DtoStructLiteralValues(const StructDeclaration* sd, co // update offsets lastoffset = os; +#if DMDV2 + // sometimes size of the initializer is less than size of the variable, + // so make sure that lastsize is correct + if (inits[i]->getType()->isSized()) + lastsize = ceil(gTargetData->getTypeSizeInBits(inits[i]->getType()) / 8.0); + else +#endif lastsize = sz; // go to next explicit init