Bug 1791 – Segmentation fault with anon class in anon class and non-constant variable init

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-01-18T10:19:00Z
Last change time
2014-02-24T15:33:37Z
Keywords
diagnostic, ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
benoit

Comments

Comment #0 by benoit — 2008-01-18T10:19:35Z
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(){ }
Comment #1 by clugdbug — 2009-04-18T03:38:13Z
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)
Comment #2 by clugdbug — 2009-05-14T06:46:48Z
Fixed DMD2.030 and 1.045