Check initializer type size in IrStruct::getDefaultInit().

This commit is contained in:
David Nadlinger
2013-05-18 19:42:39 +02:00
parent 1fed92b9b7
commit 87c8a96545

View File

@@ -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;