On Wed, Dec 21, 2016 at 4:06 PM, Jason Merrill <ja...@redhat.com> wrote: > The fourth patch fixes 42329, where we were failing to bind a template > template-parameter to a base class of the argument type.
We need to make sure that the argument is a class before we try this. Tested x86_64-pc-linux-gnu, applied to trunk.
commit 9c6ba5bf60d35afce20f8bee7e2bb2ac2efe37a4 Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Dec 22 15:19:54 2016 +0000 PR c++/78898 - ICE on constructor with TTP PR c++/42329 * pt.c (unify): Don't look for a class template from a non-class. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243890 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 301eb52..7711546 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -20292,7 +20292,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, if (TREE_CODE (parm) == BOUND_TEMPLATE_TEMPLATE_PARM) { - if (strict_in & UNIFY_ALLOW_DERIVED) + if ((strict_in & UNIFY_ALLOW_DERIVED) + && CLASS_TYPE_P (arg)) { /* First try to match ARG directly. */ tree t = try_class_unification (tparms, targs, parm, arg, diff --git a/gcc/testsuite/g++.dg/template/ttp30.C b/gcc/testsuite/g++.dg/template/ttp30.C new file mode 100644 index 0000000..f7b9ce7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp30.C @@ -0,0 +1,6 @@ +// PR c++/78898 + +struct A { + template <class T> A(T); + template <template <typename> class SmartPtr> A(SmartPtr<int>) { A(0); } +};