if (TREE_CODE (expression) == TEMPLATE_ID_EXPR)
{
- if (any_dependent_template_arguments_p
- (TREE_OPERAND (expression, 1)))
+ tree args = TREE_OPERAND (expression, 1);
+ if (any_dependent_template_arguments_p (args))
return true;
+ /* Arguments of a function template-id aren't necessarily coerced
+ yet so we must conservatively assume that the address (and not
+ just value) of the argument matters as per [temp.dep.temp]/3. */
+ for (tree arg : tree_vec_range (args))
+ if (has_value_dependent_address (arg))
+ return true;
expression = TREE_OPERAND (expression, 0);
if (identifier_p (expression))
return true;
--- /dev/null
+// PR c++/117792
+// { dg-do compile { target c++17 } }
+
+template<const int& N, class T>
+void f(T) { }
+
+template<int N, class T>
+void f(...) = delete;
+
+template<const int& N> int v;
+
+template<const int& N> struct A { };
+
+template<class T>
+void g() {
+ static constexpr int local_static = 0;
+ auto x = v<local_static>; // OK
+ A<local_static> y; // OK
+ f<local_static>(0); // ICE
+}
+
+template void g<int>();