Permalink
Browse files

fix Issue 11518 - DMD segfault on multiple template match

Incomplete `specType`, like as (T : A!T), should not be used during determination of template partial specialization order.
  • Loading branch information...
9rnsr committed Nov 15, 2013
1 parent 4f4901d commit 1261764636dfee27d927a7774a47399cca150d80
Showing with 26 additions and 7 deletions.
  1. +8 −7 src/template.c
  2. +18 −0 test/fail_compilation/ice11518.d
View
@@ -3660,12 +3660,12 @@ MATCH TypeInstance::deduceType(Scope *sc,
printf("\tthis = %d, ", ty); print();
printf("\ttparam = %d, ", tparam->ty); tparam->print();
#endif
TemplateDeclaration *tempdecl = tempinst->tempdecl->isTemplateDeclaration();
assert(tempdecl);
// Extra check
if (tparam && tparam->ty == Tinstance)
if (tparam && tparam->ty == Tinstance && tempinst->tempdecl)
{
TemplateDeclaration *tempdecl = tempinst->tempdecl->isTemplateDeclaration();
assert(tempdecl);
TypeInstance *tp = (TypeInstance *)tparam;
//printf("tempinst->tempdecl = %p\n", tempdecl);
@@ -4375,12 +4375,13 @@ void TemplateTypeParameter::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
void *TemplateTypeParameter::dummyArg()
{ Type *t;
{
Type *t;
if (specType)
t = specType;
else
{ // Use this for alias-parameter's too (?)
{
// Use this for alias-parameter's too (?)
if (!tdummy)
tdummy = new TypeIdentifier(loc, ident);
t = tdummy;
@@ -0,0 +1,18 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice11518.d(17): Error: class ice11518.B matches more than one template declaration:
fail_compilation/ice11518.d(12):B(T : A!T)
and
fail_compilation/ice11518.d(13):B(T : A!T)
---
*/
class A(T) {}
class B(T : A!T) {}
class B(T : A!T) {}
void main()
{
new B!(A!void);
}

0 comments on commit 1261764

Please sign in to comment.