[Issue 5248] CTFE Segfault when calling a function on an enum struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 16 10:17:48 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5248



--- Comment #2 from Gareth Charnock <gareth.tpc at gmail.com> 2011-01-16 10:15:52 PST ---
Okay, had time for a little more poking. Execution moves to
DotVarExp::interpret and the endless loop from here:


Expression *AssertExp::interpret(InterState *istate)
{   Expression *e;
    Expression *e1;

    if( this->e1->op == TOKaddress)
    {   // 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  // <--- something is fishy here
                && ((DotVarExp *)(istate->localThis))->e1->op == TOKthis)
                return getVarExp(loc, istate,
((DotVarExp*)(istate->localThis))->var);
            else
                return istate->localThis->interpret(istate);
    }

Apparently the compiler puts in an implicit assert(&this,"this is null") at the
beginning of member functions.

Now ade->e1->op == TOKthis is true by the time execution reaches the inner if
so why is ade->e1->op == TOKdotvar being tested? That statement is always
false. If we replace ade->e1->op == TOKdotvar with true the compiler accepts
the sample program.

The question is, what is getVarExp? and why might return
istate->localThis->interpret(istate); be the wrong thing to do?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list