diff --git a/gen/toir.cpp b/gen/toir.cpp index 56402d47..b5a3ddcf 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -888,10 +888,23 @@ DValue* AddrExp::toElem(IRState* p) return v; } Logger::println("is nothing special"); - LLValue* lval = v->getLVal(); + + // we special case here, since apparently taking the address of a slice is ok + LLValue* lval; + if (v->isLVal()) + lval = v->getLVal(); + else + { + assert(v->isSlice()); + LLValue* rval = v->getRVal(); + lval = DtoAlloca(rval->getType(), ".tmp_slice_storage"); + DtoStore(rval, lval); + } + if (Logger::enabled()) Logger::cout() << "lval: " << *lval << '\n'; - return new DImValue(type, DtoBitCast(v->getLVal(), DtoType(type))); + + return new DImValue(type, DtoBitCast(lval, DtoType(type))); } LLConstant* AddrExp::toConstElem(IRState* p) diff --git a/tests/mini/slices2.d b/tests/mini/slices2.d new file mode 100644 index 00000000..37ffc06b --- /dev/null +++ b/tests/mini/slices2.d @@ -0,0 +1,5 @@ +void main() +{ + int[10] arr = void; + int[]* ptr = &arr[1..3]; +}