Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 11518 - DMD segfault on multiple template match #2769

Merged
merged 1 commit into from
Nov 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions test/fail_compilation/ice11518.d
Original file line number Diff line number Diff line change
@@ -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);
}