Bug 8988 – Segfault with circular derived class template
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-09T08:51:00Z
Last change time
2013-10-06T23:52:02Z
Keywords
ice
Assigned to
nobody
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2012-11-09T08:51:01Z
Crashes DMD 2.060, should pass compilation:
template ID(alias T){ alias T ID; }
template GetParent(T){
alias ID!(mixin((()=>(new T).foo())())) GetParent;
}
class B{ auto foo(){ return "A"; }}
class A: GetParent!A{
override foo(){ return "B"; }
}
Comment #1 by andrej.mitrovich — 2012-11-09T08:55:09Z
Slightly reduced:
template GetParent(T)
{
alias Object GetParent;
enum x = (()=>(new A()).foo())();
}
class A : GetParent!A
{
string foo(){ return "Object"; }
}
The segfault is in ClassDeclaration::searchBase:
Dsymbol *cdb = b->type->isClassHandle();
if (cdb->ident->equals(ident)) // offending line
cdb is not checked for NULL.
Comment #2 by clugdbug — 2012-12-10T00:57:21Z
Not related to CTFE, also applies to D1. Bit hard to describe.
Reduced test case:
----
template Bug8988(T)
{
alias Object xxx;
alias typeof( A8988.init.foo) zzz;
}
class A8988 : Bug8988!(A8988).xxx
{
alias int foo;
}
Comment #3 by clugdbug — 2012-12-10T02:29:47Z
This might be the same as bug 8466. At least, it is segfaulting in the same place.
Comment #4 by bugzilla — 2013-10-06T23:52:02Z
All test cases compile successfully with 2.064 head.