diff --git a/gen/toir.cpp b/gen/toir.cpp index 5cd18f4f..80554be7 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -611,9 +611,8 @@ DValue* AddExp::toElem(IRState* p) if (e1type != e2type) { if (e1type->ty == Tpointer) { Logger::println("add to pointer"); - if (r->isConst()) { - llvm::ConstantInt* cofs = llvm::cast(r->isConst()->c); - if (cofs->isZero()) { + if (DConstValue* cv = r->isConst()) { + if (cv->c->isNullValue()) { Logger::println("is zero"); return new DImValue(type, l->getRVal()); }