Permalink
Browse files

Merge pull request #2769 from 9rnsr/fix11518

Issue 11518 - DMD segfault on multiple template match
  • Loading branch information...
MartinNowak committed Nov 17, 2013
2 parents ee2e88a + 1261764 commit f6088fc9eb7eccea51337a20925b8eefeba60096
Showing with 26 additions and 7 deletions.
  1. +8 −7 src/template.c
  2. +18 −0 test/fail_compilation/ice11518.d
View
@@ -3666,12 +3666,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);
@@ -4381,12 +4381,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 f6088fc

Please sign in to comment.