Calling strip_inheriting_ctors on a FUNCTION_DECL was returning a TEMPLATE_DECL; we should make sure we return the same tree code that we started with.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit f7ef6e8372fcb279349576f769fac34db70c87bf Author: Jason Merrill <ja...@redhat.com> Date: Tue Dec 20 07:45:02 2016 -0500 PR c++/78767 - ICE with inherited constructor default argument * method.c (strip_inheriting_ctors): Strip template as appropriate. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 73d42b1..a5271a4 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -496,14 +496,18 @@ forward_parm (tree parm) constructor from a (possibly indirect) base class. */ tree -strip_inheriting_ctors (tree fn) +strip_inheriting_ctors (tree dfn) { gcc_assert (flag_new_inheriting_ctors); + tree fn = dfn; while (tree inh = DECL_INHERITED_CTOR (fn)) { inh = OVL_CURRENT (inh); fn = inh; } + if (TREE_CODE (fn) == TEMPLATE_DECL + && TREE_CODE (dfn) == FUNCTION_DECL) + fn = DECL_TEMPLATE_RESULT (fn); return fn; } diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C new file mode 100644 index 0000000..7c1fae0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor24.C @@ -0,0 +1,15 @@ +// PR c++/78767 +// { dg-do compile { target c++11 } } + +template <class T> struct A +{ + template <class U> + A(U, U = 42); +}; + +struct B: A<int> +{ + using A::A; +}; + +B b(24);