@@ -2902,7 +2902,8 @@ public:
29022902 result = CTFEExp.cantexp;
29032903 return ;
29042904 }
2905- auto sle = new StructLiteralExp(e.loc, e.sd, expsx);
2905+ emplaceExp! (StructLiteralExp)(pue, e.loc, e.sd, expsx);
2906+ auto sle = cast (StructLiteralExp)pue.exp();
29062907 sle.type = e.type;
29072908 sle.ownedByCtfe = OwnedBy.ctfe;
29082909 result = sle;
@@ -3010,7 +3011,8 @@ public:
30103011 }
30113012 if (exceptionOrCant(result))
30123013 return ;
3013- result = new AddrExp(e.loc, result, e.type);
3014+ emplaceExp! (AddrExp)(pue, e.loc, result, e.type);
3015+ result = pue.exp();
30143016 return ;
30153017 }
30163018 if (e.newtype.toBasetype().ty == Tclass)
@@ -3104,9 +3106,10 @@ public:
31043106 ae.type = e.newtype.arrayOf();
31053107 ae.ownedByCtfe = OwnedBy.ctfe;
31063108
3107- result = new IndexExp(e.loc, ae, new IntegerExp(Loc.initial, 0 , Type.tsize_t));
3108- result.type = e.newtype;
3109- result = new AddrExp(e.loc, result, e.type);
3109+ auto ei = new IndexExp(e.loc, ae, new IntegerExp(Loc.initial, 0 , Type.tsize_t));
3110+ ei.type = e.newtype;
3111+ emplaceExp! (AddrExp)(pue, e.loc, ei, e.type);
3112+ result = pue.exp();
31103113 return ;
31113114 }
31123115 e.error(" cannot interpret `%s` at compile time" , e.toChars());
@@ -3153,15 +3156,17 @@ public:
31533156 {
31543157 printf(" %s DotTypeExp::interpret() %s\n " , e.loc.toChars(), e.toChars());
31553158 }
3156- Expression e1 = interpret(e.e1, istate);
3159+ UnionExp ue = void ;
3160+ Expression e1 = interpret(&ue, e.e1, istate);
31573161 if (exceptionOrCant(e1))
31583162 return ;
31593163 if (e1 == e.e1)
31603164 result = e; // optimize: reuse this CTFE reference
31613165 else
31623166 {
3163- result = e.copy();
3164- (cast (DotTypeExp)result).e1 = e1;
3167+ auto edt = cast (DotTypeExp)e.copy();
3168+ edt.e1 = (e1 == ue.exp()) ? e1.copy() : e1; // don't return pointer to ue
3169+ result = edt;
31653170 }
31663171 }
31673172
@@ -4761,7 +4766,8 @@ public:
47614766 res = ! andand;
47624767 else if (andand ? isTrueBool(result) : result.isBool(false ))
47634768 {
4764- result = interpret(e.e2, istate);
4769+ UnionExp ue2;
4770+ result = interpret(&ue2, e.e2, istate);
47654771 if (exceptionOrCant(result))
47664772 return ;
47674773 if (result.op == TOK .voidExpression)
@@ -4788,7 +4794,10 @@ public:
47884794 return ;
47894795 }
47904796 if (goal != ctfeNeedNothing)
4791- result = new IntegerExp(e.loc, res, e.type);
4797+ {
4798+ emplaceExp! (IntegerExp)(pue, e.loc, res, e.type);
4799+ result = pue.exp();
4800+ }
47924801 }
47934802
47944803
0 commit comments