From 77b5e841dd3b4d069f33684c4a30e7d409d43f80 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 1 Oct 2008 19:15:01 +0200 Subject: [PATCH] Make invalid compile time casts an error instead of asserting. --- gen/toir.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index 37fbcc2b..bb8950a7 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -829,10 +829,12 @@ LLConstant* CastExp::toConstElem(IRState* p) LOG_SCOPE; LLConstant* c = e1->toConstElem(p); - assert(isaPointer(c->getType())); - const LLType* lltype = DtoType(type); - assert(isaPointer(lltype)); + + if(!isaPointer(c->getType()) || !isaPointer(lltype)) { + error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars()); + fatal(); + } return llvm::ConstantExpr::getBitCast(c, lltype); }