diff --git a/gen/classes.cpp b/gen/classes.cpp index a5dde05a..f5daca9f 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -837,9 +837,14 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp) { Logger::println("Resolving nested context"); LOG_SCOPE; + // this value might be zero if it was not necessary to generate it ... LLValue* nest = gIR->func()->nestedVar; + // ... then revert to the this ptr if there is one if (!nest) nest = gIR->func()->thisVar; + // ... or just use zero, since it must be unused. + if (!nest) + nest = llvm::ConstantPointerNull::get(getVoidPtrType()); assert(nest); LLValue* gep = DtoGEPi(mem,0,2,"tmp"); nest = DtoBitCast(nest, gep->getType()->getContainedType(0));