[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 12:22:05 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5248
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #3 from Don <clugdbug at yahoo.com.au> 2011-01-16 12:20:07 PST ---
Excellent!
(In reply to comment #2)
> 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?
If it is returning by reference, it needs to return a VarExp, whereas
localThis->interpret() returns the value of 'this' (ie, an rvalue).
You're right about the problem line. That should definitely be:
- if (ade->e1->op == TOKdotvar
+ if (istate->localThis->op == TOKdotvar
&& ((DotVarExp *)(istate->localThis))->e1->op == TOKthis)
return getVarExp(loc, istate,
--
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