5242 – self referencing template constraint crashes compiler

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5242 - self referencing template constraint crashes compiler
Summary: self referencing template constraint crashes compiler
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2010年11月19日 14:30 UTC by Michal Minich
Modified: 2010年12月22日 23:38 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 Michal Minich 2010年11月19日 14:30:59 UTC
I wanted to restrict template parameter X to allow only derived classes of A.
class A (X : A!(X)) { }
class B : A!(B) { }
void main () {}
Comment 1 Don 2010年11月19日 14:42:41 UTC
PATCH: template.c, line 2509
void deduceBaseClassParameters(BaseClass *b,
 Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes,
 Objects *best, int &numBaseClassMatches)
{
- TemplateInstance *parti = b->base->parent->isTemplateInstance();
+ TemplateInstance *parti = b->base ? b->base->parent->isTemplateInstance() : NULL;
 if (parti)
 {
 // Make a temporary copy of dedtypes so we don't destroy it
 Objects *tmpdedtypes = new Objects();
Comment 2 Walter Bright 2010年12月22日 23:38:47 UTC
http://www.dsource.org/projects/dmd/changeset/814 


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