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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1791 - Segmentation fault with anon class in anon class and non-constant variable init
Summary: Segmentation fault with anon class in anon class and non-constant variable init
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic, ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2008年01月18日 10:19 UTC by Frank Benoit
Modified: 2014年02月24日 15:33 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Frank Benoit 2008年01月18日 10:19:35 UTC
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 Don 2009年04月18日 03:38:13 UTC
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 Don 2009年05月14日 06:46:48 UTC
Fixed DMD2.030 and 1.045


AltStyle によって変換されたページ (->オリジナル) /