# HG changeset patch # User Christian Kamm # Date 1243539914 -7200 # Node ID 087dafe5262a39bd3d7a3a5dcdce63713fead73a # Parent ae70c438b281c89c264112d6354078af59439eb4 Make sure complex -> integral casts are not used when casting to bool. Error instead of assert on unimplemented cast. diff -r ae70c438b281 -r 087dafe5262a gen/complex.cpp --- a/gen/complex.cpp Thu May 28 20:26:26 2009 +0200 +++ b/gen/complex.cpp Thu May 28 21:45:14 2009 +0200 @@ -410,7 +410,7 @@ DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to) { Type* to = _to->toBasetype(); - Type* vty = val->getType(); + Type* vty = val->getType()->toBasetype(); if (to->iscomplex()) { if (vty->size() == to->size()) return val; @@ -438,6 +438,9 @@ DImValue* im = new DImValue(to, impart); return DtoCastFloat(loc, im, to); } + else if (to->ty == Tbool) { + return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); + } else if (to->isfloating() || to->isintegral()) { // FIXME: this loads both values, even when we only need one LLValue* v = val->getRVal(); @@ -453,10 +456,7 @@ DImValue* re = new DImValue(extractty, repart); return DtoCastFloat(loc, re, to); } - else if (to->ty == Tbool) { - return new DImValue(_to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); - } else - assert(0); + error(loc, "Don't know how to cast %s to %s", vty->toChars(), to->toChars()); }