# HG changeset patch # User ChristianK # Date 1214770957 -7200 # Node ID a498b736a0bd794f1e8a7eccb9a3974afa262c54 # Parent 553f844ae5b9ff3a1f0e3128e939d283e97a7b2e [svn r334] Produce an error for zero-size types instead of segfaulting. diff -r 553f844ae5b9 -r a498b736a0bd gen/toir.cpp --- a/gen/toir.cpp Sun Jun 29 22:07:15 2008 +0200 +++ b/gen/toir.cpp Sun Jun 29 22:22:37 2008 +0200 @@ -72,6 +72,11 @@ else { // allocate storage on the stack const LLType* lltype = DtoType(vd->type); + if(gTargetData->getTypeSizeInBits(lltype) == 0) + { + error("Allocating a variable of type %s and size zero is not implemented. (the behaviour of alloca with zero size is undefined)", vd->type->toChars()); + fatal(); + } llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); //allocainst->setAlignment(vd->type->alignsize()); // TODO assert(!vd->ir.irLocal);