[Issue 1791] Segmentation fault with anon class in anon class and non-constant variable init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 18 01:38:06 PDT 2009


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


clugdbug at yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, patch




------- Comment #1 from clugdbug at yahoo.com.au  2009-04-18 03:38 -------
Don't know what the error message should be, but this patch at least fixes the
segfault for DMD2.028.
Note that in this bug, there are also error messages with no line number.

Error: variable this forward referenced
Error: variable this forward referenced
fog.d(12): Error: No parent
-----

The line number is known in mtype.c line 6070, but isn't known in the variable
declaration itself.

---
 v = s->isVarDeclaration();
    if (v && !v->isDataseg())
    {   Expression *ei = v->getConstInitializer();

---



Index: expression.c
===================================================================
--- expression.c        (revision 23)
+++ expression.c        (working copy)
@@ -5673,12 +5674,15 @@
                t1 = t1->nextOf();

            type = type->addMod(t1->mod);
-
+       
+               if (!var->toParent()) {
+                               error("No parent");
+                               return this;
+               }
            AggregateDeclaration *ad =
var->toParent()->isAggregateDeclaration();
            e1 = getRightThis(loc, sc, ad, e1, var);
            if (!sc->noaccesscheck)
                accessCheck(loc, sc, e1, var);
-
            VarDeclaration *v = var->isVarDeclaration();
            Expression *e = expandVar(WANTvalue, v);
            if (e)


-- 



More information about the Digitalmars-d-bugs mailing list