From 2c0f68b5d2035e013cad172cb48ca4b4501e7118 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 23 Apr 2011 18:16:33 +0200 Subject: [PATCH] Merged DMD commit 645b5d8797768bced8db0c32dfa03e9290d0ced0: 5248 CTFE Segfault when calling a function on an enum struct Fix the D1 version of this bug, which causes a stack overflow rather than a segfault: compiler inserts assert(this, "null this") whereas for D2 it is assert(&this, "null this") --- dmd/interpret.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dmd/interpret.c b/dmd/interpret.c index 0db2c72e..4e64bee7 100644 --- a/dmd/interpret.c +++ b/dmd/interpret.c @@ -3102,7 +3102,7 @@ Expression *AssertExp::interpret(InterState *istate) { // Special case: deal with compiler-inserted assert(&this, "null this") AddrExp *ade = (AddrExp *)this->e1; if (ade->e1->op == TOKthis && istate->localThis) - if (ade->e1->op == TOKdotvar + if (istate->localThis->op == TOKdotvar && ((DotVarExp *)(istate->localThis))->e1->op == TOKthis) return getVarExp(loc, istate, ((DotVarExp*)(istate->localThis))->var); else @@ -3111,7 +3111,13 @@ Expression *AssertExp::interpret(InterState *istate) if (this->e1->op == TOKthis) { if (istate->localThis) - return istate->localThis->interpret(istate); + { + if (istate->localThis->op == TOKdotvar + && ((DotVarExp *)(istate->localThis))->e1->op == TOKthis) + return getVarExp(loc, istate, ((DotVarExp*)(istate->localThis))->var); + else + return istate->localThis->interpret(istate); + } } e1 = this->e1->interpret(istate); if (e1 == EXP_CANT_INTERPRET)