We weren't explicitly treating a pack index specifier as a non-deduced
context (as per [temp.deduct.type]/5), leading to an ICE for the first
testcase below.
PR c++/121795
gcc/cp/ChangeLog:
* pt.cc (unify) <case PACK_INDEX_TYPE>: New non-deduced context
case.
gcc/testsuite/ChangeLog:
* g++.dg/cpp26/pack-indexing17.C: New test.
* g++.dg/cpp26/pack-indexing17a.C: New test.
Reviewed-by: Marek Polacek <polacek@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
case TYPEOF_TYPE:
case DECLTYPE_TYPE:
case TRAIT_TYPE:
- /* Cannot deduce anything from TYPEOF_TYPE, DECLTYPE_TYPE,
- or TRAIT_TYPE nodes. */
+ case PACK_INDEX_TYPE:
+ /* These are non-deduced contexts. */
return unify_success (explain_p);
case ERROR_MARK:
--- /dev/null
+// PR c++/121795
+// { dg-do compile { target c++26 } }
+
+template<class T, class... Ts>
+struct A;
+
+template<class... Ts>
+struct A<Ts...[sizeof...(Ts)-1], Ts...> { };
+
+A<int, int> x;
+A<char, int> y; // { dg-error "incomplete" }
--- /dev/null
+// PR c++/121795
+// A version of pack-indexing17.C using a nontype pack.
+// { dg-do compile { target c++26 } }
+
+template<int N, int... Ns>
+struct A;
+
+template<int... Ns>
+struct A<Ns...[sizeof...(Ns)-1], Ns...> { };
+
+A<0, 0> x;
+A<0, 1> y; // { dg-error "incomplete" }