Bug 3803 – compiler segfaults

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Mac OS X
Creation time
2010-02-14T09:27:00Z
Last change time
2014-02-15T02:28:31Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
fawzi

Comments

Comment #0 by fawzi — 2010-02-14T09:27:53Z
The following (incorrect) code segfaults the compiler I suppose that it is connected with something segfault on correct code of xf.omg.core.CoordSys and that it is connected with #3792 {{{ struct S { int x; template T(int val) { const P T = { val }; // the P here is an error it should be S } } template V(R,int val){ const R V=R.T!(val); } const S x = V!(S,0); }}}
Comment #1 by clugdbug — 2010-02-15T01:16:22Z
This was a regression since 1.053. Suprisingly, it is fixed by bug 3767, in svn 367.
Comment #2 by fawzi — 2010-02-27T15:49:51Z
I have tried to find the problem using ldc (that shares the problem), also using the larger correct code that shows the problem (stacktraces are similar). The problem seems to be located in expression.c:5048 Dsymbol *s = ti->inst->toAlias(); ti->inst == NULL, so that the compiler segfaults. In the correct code I am not sure if inst is NULL because a single pass cannot instantiate the template, or because it is in an is expression. In any case simply catching this case and return new ErrorExp(); doesn't seem to be enough (then I have other problems).
Comment #3 by fawzi — 2010-02-28T16:02:28Z
a clean compile, and my fix doesn't look to bad. klickverbot even tested dstess, and it did not make anything worse. It might not be the correct fix, but still improves things. {{{ diff -r 9cc791423e20 dmd/expression.c --- a/dmd/expression.c Thu Feb 25 17:12:54 2010 -0700 +++ b/dmd/expression.c Sun Feb 28 23:59:36 2010 +0100 -5946,6 +5946,7 @@ eleft = dte->e1; ti->tempdecl = td; ti->semantic(sc); + if (ti->inst == NULL) return new ErrorExp(); Dsymbol *s = ti->inst->toAlias(); Declaration *v = s->isDeclaration(); if (v) }}}
Comment #4 by Kosmonaut — 2010-03-02T18:41:32Z
Comment #5 by bugzilla — 2010-03-08T22:23:57Z
Fixed dmd 1.057 and 2.041