changeset 624:eb444ed4a2d3

Make invalid compile time casts an error instead of asserting.
author Christian Kamm <kamm incasoftware de>
date Wed, 01 Oct 2008 19:15:01 +0200
parents fe3c7af578eb
children 7e0a766fef47
files gen/toir.cpp
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gen/toir.cpp	Wed Oct 01 18:33:21 2008 +0200
+++ b/gen/toir.cpp	Wed Oct 01 19:15:01 2008 +0200
@@ -829,10 +829,12 @@
     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);
 }