Bug 4094 – ICE(expression.c): recursive struct templates with type inference
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-04-15T11:43:00Z
Last change time
2015-06-09T01:27:39Z
Keywords
ice, pull
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2010-04-15T11:43:16Z
A simple variation of bug 4093.
struct Zug(int Z){
const bahn = Bug4094!(0).hof.bahn;
}
struct Bug4094(int Q){
Zug!(0) hof;
}
const a = Zug!(0).bahn;
---------
Assertion failure: 'type' on line 6192 in file 'expression.c'
abnormal program termination
Comment #1 by clugdbug — 2010-04-20T01:33:24Z
mtype.c, TypeStruct::dotExp line 6645. Should not be able to declare a variable in terms of itself. This can be detected via the 'inuse' member of the VarDeclaration. Something I don't really like about this is that it introduces a long-range coupling into the code (the 'inuse' member is not well documented, and it's also used for a completely different purpose in toDecoBuffer()).
Note that this patch also fixes bug 4093, and various other kinds of recursive definitions (the existing cases which don't ICE just loop until the stack overflow probe catches them, generating a "recursive template definition" error message).
===
if (v && !v->isDataseg())
{
Expression *ei = v->getConstInitializer();
if (ei)
{ e = ei->copy(); // need to copy it if it's a StringExp
+ if (v->inuse)
+ {
+ v->error("recursive declaration");
+ return new ErrorExp();
+ }
e = e->semantic(sc);
return e;
}
}