From 87c8a96545e7e693a373e3ab4add139680eaaecb Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 18 May 2013 19:42:39 +0200 Subject: [PATCH] Check initializer type size in IrStruct::getDefaultInit(). --- ir/irstruct.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 3e749cf9..c8f0f15a 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -92,6 +92,11 @@ llvm::Constant * IrStruct::getDefaultInit() types.push_back((*itr)->getType()); init_type->setBody(types, packed); + // Whatever type we end up with due to unions, ..., it should match the + // the LLVM type corresponding to the D struct type in size. + assert(getTypeStoreSize(DtoType(type)) <= getTypeStoreSize(init_type) && + "Struct initializer type mismatch, encountered type too small."); + // build constant struct constInit = LLConstantStruct::get(init_type, constants); IF_LOG Logger::cout() << "final default initializer: " << *constInit << std::endl;