]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: template-id dependence wrt local static arg [PR117792]
authorPatrick Palka <ppalka@redhat.com>
Thu, 9 Jan 2025 15:49:45 +0000 (10:49 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 9 Jan 2025 15:49:45 +0000 (10:49 -0500)
commit40f0f6ab75a391906bed40cbdc098b0df3a91af7
tree78cbe46151ae81d7f1b08e7273d5e830faad59aa
parent823101941530d1aa0837f4e74436ea3e027c9241
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 <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp1z/nontype7.C [new file with mode: 0644]