https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121981
--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:be81c5af3dc18c4ceaf193be386ae8bbaed08168 commit r15-10368-gbe81c5af3dc18c4ceaf193be386ae8bbaed08168 Author: Patrick Palka <ppa...@redhat.com> Date: Sat Sep 20 10:45:22 2025 -0400 c++: find_template_parameters and NTTPs [PR121981] Here the normal form of the two immediately-declared D<<placeholder>, V> constraints is the same, so we rightfully share the normal form between them. We first compute the normal form from the context of auto deduction for W in which case the placeholder has level 2 where the set of in-scope template parameters has depth 2 (a dummy level is added from normalize_placeholder_type_constraints). Naturally the atomic constraint only depends on the template parameter V of depth 1 index 0. The depth 2 of current_template_parms however means that find_template_parameters when it sees V within the atomic constraint will recurse into its TREE_TYPE, an auto of level 2, and mark the atomic constraint as also depending on the template parameter of depth 2 index 0, which is clearly wrong. Later during constraint checking for B we ICE within the satisfaction cache since we lack two levels of template arguments supposedly needed by the cached atomic constraint. I think when find_template_parameters sees an NTTP, it doesn't need to walk its TREE_TYPE because NTTP substitution is done obliviously with respect to its type -- only the corresponding NTTP argument matters, not other template arguments possibly used within its type. This is most clearly true for (unconstrained) auto NTTPs as in the testcase, but also true for other NTTPs. Doing so fixes the testcase because we no longer record any depth 2 when walking V within the atomic constraint. PR c++/121981 gcc/cp/ChangeLog: * pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>: Don't walk TREE_TYPE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-placeholder15.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit 396e9118849c4b918eaf3edcfa60d36e2b973019)