https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117792
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:4dbfc2ff0a84edf6addeaa425272a5beacbbc7db commit r14-11175-g4dbfc2ff0a84edf6addeaa425272a5beacbbc7db Author: Patrick Palka <ppa...@redhat.com> Date: Thu Jan 9 10:49:45 2025 -0500 c++: template-id dependence wrt local static arg [PR117792] Here we end up ICEing at instantiation time for the call to f<local_static> ultimately because we wrongly consider the call to be non-dependent, and so we specialize f ahead of time and then get confused when fully substituting this specialization. The call is dependent due to [temp.dep.temp]/3 and we miss that because function template-id arguments aren't coerced until overload resolution, and so the local static template argument lacks an implicit cast to reference type that value_dependent_expression_p looks for before considering dependence of the address. Other kinds of template-ids aren't affected since they're coerced ahead of time. So when considering dependence of a function template-id, we need to conservatively consider dependence of the address of each argument (if applicable). PR c++/117792 gcc/cp/ChangeLog: * pt.cc (type_dependent_expression_p): Consider the dependence of the address of each template argument of a function template-id. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype7.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit 40f0f6ab75a391906bed40cbdc098b0df3a91af7)