From d739588d4a1c59e2c10c496ecf5703bdd61bba9a Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sat, 21 Apr 2012 18:24:10 +0400 Subject: [PATCH] Fix dmd bug 7504: Cannot assign an object of type 'typeof(null)' to an array --- gen/llvmhelpers.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 17b7119a..88a9c4f0 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -748,6 +748,15 @@ DValue* DtoCastNull(Loc& loc, DValue* val, Type* to) LLValue *rval = DtoBitCast(val->getRVal(), tolltype); return new DImValue(to, rval); } + if (totype->ty == Tarray) + { + if (Logger::enabled()) + Logger::cout() << "cast null to array: " << *tolltype << '\n'; + LLValue *rval = val->getRVal(); + rval = DtoBitCast(rval, DtoType(to->nextOf()->pointerTo())); + rval = DtoAggrPair(DtoConstSize_t(0), rval, "null_array"); + return new DImValue(to, rval); + } else { error(loc, "invalid cast from null to '%s'", to->toChars());