[Bug 49] ICE when using tuple over member variable in more than one method

gdc-bugzilla at gdcproject.org gdc-bugzilla at gdcproject.org
Tue Apr 9 06:41:15 PDT 2013


http://bugzilla.gdcproject.org/show_bug.cgi?id=49

--- Comment #6 from Iain Buclaw <ibuclaw at gdcproject.org> 2013-04-09 13:41:15 UTC ---
(In reply to comment #5)
> (In reply to comment #2)
> > (In reply to comment #0)
> > > test.d:
> > > 
> > > template Tuple(Stuff ...) {
> > >     alias Stuff Tuple;
> > > }
> > > struct S {
> > >     int i;
> > >     alias Tuple!i t;
> > >     void a() {
> > >         auto x = t;
> > >     }
> > >     void b() {
> > >         auto x = t;
> > >     }
> > > }
> > 
> > 
> > Tracked down to the following:
> > 
> > void a() {
> >   // OK: 'this' has decl context of 'a'
> >   (int) x = tuple(this.i);
> > }
> > 
> > void b() {
> >   // WRONG: 'this' has decl context of 'a'
> >   (int) x = tuple(this.i);
> > }
> 
> 
> Looks like TupleExp's are cached and re-used.  This is why when the
> TupleExp::semantic ran in b() has a parent of 'a'


Fix - Not sure if there are any other cases where this could happen.


--- a/gcc/d/dfrontend/expression.c
+++ b/gcc/d/dfrontend/expression.c
@@ -5200,7 +5200,7 @@ TupleExp::TupleExp(Loc loc, TupleDeclaration *tup)
         if (o->dyncast() == DYNCAST_EXPRESSION)
         {
             Expression *e = (Expression *)o;
-            if (e->op == TOKdsymbol)
+            if (e->op == TOKdsymbol || e->op == TOKdotvar)
                 e = e->syntaxCopy();
             exps->push(e);
         }

-- 
Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the D.gnu mailing list