Bug 1787 – Compiler segfaults on circular references.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2008-01-15T04:54:00Z
Last change time
2014-02-24T15:32:55Z
Keywords
ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
aziz.koeksal

Comments

Comment #0 by aziz.koeksal — 2008-01-15T04:54:41Z
// 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 by smjg — 2008-09-09T16:14:13Z
Related to issue 713? WFM 1.035 Windows. Has it gone away, or is it platform parity?
Comment #2 by clugdbug — 2009-04-18T02:47:37Z
(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 by clugdbug — 2009-05-15T00:17:39Z
Was fixed in DMD2.030, still segfaults in DMD1.045.
Comment #4 by clugdbug — 2009-08-13T00:22:15Z
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 by bugzilla — 2009-10-13T13:50:16Z
Fixed dmd 1.049