template <typename> struct A; template <bool> struct B; template <unsigned long> struct in_place_index_t {}; template <bool B, typename> using enable_if_t = typename B<B>::type; template <typename F> using invoke_result_t = typename F::type; template <long> using type_pack_element = int; template <long> using type_pack_element_t = type_pack_element<1>; template <typename> struct traits; class C { public: template <unsigned long I> C(in_place_index_t<I>); }; template <typename> class destructor : C { using super = C; using super::super; } ; class constructor : destructor<traits<int>> { using super = destructor; using super::super; }; class F : constructor { using super = constructor; using super::super; }; template <typename> class copy_constructor : F { using super = F; using super::super; } ; class D : copy_constructor<traits<int>> { using super = copy_constructor; using super::super; }; class G : D { using super = D; using super::super; }; class H : G { using super = G; using super::super; }; class I : H { using super = H; using super::super; }; template <typename T> using best_match = invoke_result_t<T>; class variant { public: variant() : impl_(in_place_index_t<0>{}) {} template <typename Arg, long I = best_match<Arg>::value, typename = type_pack_element_t<I>, enable_if_t<A<Arg>::value, int>> variant(Arg &&); I impl_; }; struct S { variant var; }; int main() { S s; } $ ./cc1plus.258039 -quiet x.cc x.cc: In substitution of ‘template<long int <anonymous> > using type_pack_element_t = type_pack_element<1> [with long int <anonymous> = I]’: x.cc:54:13: required by substitution of ‘template<class Arg, long int I, class, typename B<A< <template-parameter-1-1> >::value>::type <anonymous> > variant::variant(Arg&&) [with Arg = const variant&; long int I = <missing>; <template-parameter-1-3> = <missing>; typename B<A< <template-parameter-1-1> >::value>::type <anonymous> = <missing>]’ x.cc:62:16: required from here x.cc:54:13: internal compiler error: unexpected expression ‘I’ of kind template_parm_index typename = type_pack_element_t<I>, enable_if_t<A<Arg>::value, int>> ^~~~~~~~ 0x86a8b4 cxx_eval_constant_expression ../../gcc/cp/constexpr.c:4767 0x86ac7b cxx_eval_outermost_constant_expr ../../gcc/cp/constexpr.c:4826 0x86b832 maybe_constant_value(tree_node*, tree_node*) ../../gcc/cp/constexpr.c:5044 0xa10fe8 convert_nontype_argument ../../gcc/cp/pt.c:6542 0xa15cb9 convert_template_argument ../../gcc/cp/pt.c:7862 0xa17772 coerce_template_parms ../../gcc/cp/pt.c:8324 0xa17d1d coerce_innermost_template_parms ../../gcc/cp/pt.c:8429 0xa4d22b instantiate_alias_template ../../gcc/cp/pt.c:18742 0xa32049 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/cp/pt.c:13712 0xa23c15 tsubst_template_arg ../../gcc/cp/pt.c:10941 0xa50c18 type_unification_real ../../gcc/cp/pt.c:19851 0xa4e388 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool) ../../gcc/cp/pt.c:19039 0x7fd8a0 add_template_candidate_real ../../gcc/cp/call.c:3176 0x7fddf2 add_template_candidate ../../gcc/cp/call.c:3258 0x80641e add_candidates ../../gcc/cp/call.c:5525 0x81668e build_new_method_call_1 ../../gcc/cp/call.c:9154 0x817c47 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ../../gcc/cp/call.c:9361 0x969717 locate_fn_flags ../../gcc/cp/method.c:1024 0x96ab13 walk_field_subobs ../../gcc/cp/method.c:1439 0x96ba99 synthesized_method_walk ../../gcc/cp/method.c:1744 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
Started with r258039.
Author: jason Date: Sat Mar 10 03:34:29 2018 New Revision: 258407 URL: https://gcc.gnu.org/viewcvs?rev=258407&root=gcc&view=rev Log: PR c++/84785 - ICE with alias template and default targs. * pt.c (type_unification_real): Set processing_template_decl if saw_undeduced == 1. Added: trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Author: jason Date: Sat Mar 10 03:35:17 2018 New Revision: 258409 URL: https://gcc.gnu.org/viewcvs?rev=258409&root=gcc&view=rev Log: PR c++/84785 - ICE with alias template and default targs. * pt.c (type_unification_real): Set processing_template_decl if saw_undeduced == 1. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/pt.c
Author: jason Date: Sat Mar 10 03:35:25 2018 New Revision: 258410 URL: https://gcc.gnu.org/viewcvs?rev=258410&root=gcc&view=rev Log: PR c++/84785 - ICE with alias template and default targs. * pt.c (type_unification_real): Set processing_template_decl if saw_undeduced == 1. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C Modified: branches/gcc-6-branch/gcc/cp/ChangeLog branches/gcc-6-branch/gcc/cp/pt.c
Fixed.