https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:904cbf6ae2a1e45b3a272365cca19f9dd9a27fa2 commit r10-9733-g904cbf6ae2a1e45b3a272365cca19f9dd9a27fa2 Author: Patrick Palka <ppa...@redhat.com> Date: Tue Apr 20 12:06:24 2021 -0400 c++: Fix deduction with reference NTTP [PR83476] In the testcase ref11.C below, during deduction for the call f(a), uses_deducible_template_parms returns false for the dependent specialization A<V> because the generic template argument V here is wrapped in an implicit INDIRECT_REF (formed from template_parm_to_arg). Since uses_deducible_template_parms returns false, unify_one_argument exits early without ever attempting to deduce 'n' for 'V'. This patch fixes this by making deducible_expression look through such implicit INDIRECT_REFs. gcc/cp/ChangeLog: PR c++/83476 PR c++/99885 * pt.c (deducible_expression): Look through implicit INDIRECT_REFs as well. gcc/testsuite/ChangeLog: PR c++/83476 PR c++/99885 * g++.dg/cpp1z/class-deduction85.C: New test. * g++.dg/template/ref11.C: New test. (cherry picked from commit 2ccc05a5141506fde0e20dec702c717fd67bf6ee)