diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 0cd46608..78cba750 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -571,14 +571,22 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to) Type* from = val->getType()->toBasetype(); assert(from->isintegral()); - size_t fromsz = from->size(); - size_t tosz = to->size(); - LLValue* rval = val->getRVal(); if (rval->getType() == tolltype) { return new DImValue(_to, rval); } + // Check for special DMD hack to avoid "has no effect" error. + // See expression.c, method AssignExp::semantic(), around line 11499 + llvm::ConstantInt* isConstInt = isaConstantInt(rval); + if (from == Type::tint32 && to == Type::tvoid && isConstInt->isNullValue()) + { + return val; + } + + size_t fromsz = from->size(); + size_t tosz = to->size(); + if (to->ty == Tbool) { LLValue* zero = LLConstantInt::get(rval->getType(), 0, false); rval = gIR->ir->CreateICmpNE(rval, zero, "tmp");