www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1791] New: Segmentation fault with anon class in anon class and non-constant variable init

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1791

           Summary: Segmentation fault with anon class in anon class and
                    non-constant variable init
           Product: D
           Version: 1.025
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


This is not valid D code, but obviously DMD should not segfault on this:


interface I {
}
interface K {
    void func();
}

class C{
    this(){
        I i = new class() I {
            K k = new class() K {
                void func(){
                    this.outer.outer;
                }
            };
        };
    }
    int i;
}

void main(){
}


-- 
Jan 18 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1791


clugdbug yahoo.com.au changed:

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





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)


-- 
Apr 18 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1791


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED





Fixed DMD2.030 and 1.045

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