1787 – Compiler segfaults on circular references.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1787 - Compiler segfaults on circular references.
Summary: Compiler segfaults on circular references.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P3 normal
Assignee: Walter Bright
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2008年01月15日 04:54 UTC by Aziz Köksal
Modified: 2014年02月24日 15:32 UTC (History)
2 users (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 Aziz Köksal 2008年01月15日 04:54:41 UTC
// Code snippets which kill dmd.
struct A
{ const a = B.b; }
struct B
{ const b = A.a; }
struct C
{
 const x = C.x;
}
// Some examples which don't segfault. The compiler reports errors as it should.
const x = x;
const a = b;
const b = a;
Comment 1 Stewart Gordon 2008年09月09日 16:14:13 UTC
Related to issue 713?
WFM 1.035 Windows. Has it gone away, or is it platform parity?
Comment 2 Don 2009年04月18日 02:47:37 UTC
(In reply to comment #1)
> Related to issue 713?
> 
> WFM 1.035 Windows. Has it gone away, or is it platform parity?
> 
The first example now works, but the second one segfaults:
struct C {
 const x = C.x;
}
Segfaults on DMD2.028 and 1.042 Windows.
I've patched it so that it displays:
bug.d(2): Error: variable bug.C.x cannot infer type
Patch against DMD2.028 in void VarDeclaration::semantic(Scope *sc).
Index: declaration.c
===================================================================
--- declaration.c	(revision 22)
+++ declaration.c	(working copy)
@@ -688,6 +688,7 @@
 if (!type)
 {	inuse++;
 	type = init->inferType(sc);
+	if (!type) { error("cannot infer type"); return; } 
 	inuse--;
 	inferred = 1;
Comment 3 Don 2009年05月15日 00:17:39 UTC
Was fixed in DMD2.030, still segfaults in DMD1.045.
Comment 4 Don 2009年08月13日 00:22:15 UTC
This patch isn't great, but since it's already got a proper fix in D2, it might be OK.
Index: mtype.c
===================================================================
--- mtype.c	(revision 192)
+++ mtype.c	(working copy)
@@ -4313,6 +4313,11 @@
 s = s->toAlias();
 
 v = s->isVarDeclaration();
+	if (v && v->isConst() && !v->type) {
+		// BUG 1787. TODO: This isn't the best place for this error message, but it prevents a segfault
+		error(e->loc, "Cannot infer type of %s", v->toChars());
+		return e; 
+	}
 if (v && v->isConst() && v->type->toBasetype()->ty != Tsarray)
 {	ExpInitializer *ei = v->getExpInitializer();
Comment 5 Walter Bright 2009年10月13日 13:50:16 UTC
Fixed dmd 1.049


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