From: Patrick Palka Date: Fri, 12 Sep 2025 18:21:25 +0000 (-0400) Subject: c++: pack indexing is a non-deduced context [PR121795] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e3230f4fed0d41e790d68c2534c057911bab35c;p=thirdparty%2Fgcc.git c++: pack indexing is a non-deduced context [PR121795] 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) : 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 Reviewed-by: Jason Merrill --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 7f0d16f217e..b7cb807d8da 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -26301,8 +26301,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, 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: diff --git a/gcc/testsuite/g++.dg/cpp26/pack-indexing17.C b/gcc/testsuite/g++.dg/cpp26/pack-indexing17.C new file mode 100644 index 00000000000..8450ed64bd5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp26/pack-indexing17.C @@ -0,0 +1,11 @@ +// PR c++/121795 +// { dg-do compile { target c++26 } } + +template +struct A; + +template +struct A { }; + +A x; +A y; // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/cpp26/pack-indexing17a.C b/gcc/testsuite/g++.dg/cpp26/pack-indexing17a.C new file mode 100644 index 00000000000..445f0d94ad2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp26/pack-indexing17a.C @@ -0,0 +1,12 @@ +// PR c++/121795 +// A version of pack-indexing17.C using a nontype pack. +// { dg-do compile { target c++26 } } + +template +struct A; + +template +struct A { }; + +A<0, 0> x; +A<0, 1> y; // { dg-error "incomplete" }