===================================================================
@@ -9603,6 +9603,16 @@ cxx_eval_constant_expression (const constexpr_call
break;
case COMPONENT_REF:
+ if (is_overloaded_fn (t))
+ {
+ /* We can only get here in checking mode via
+ build_non_dependent_expr, because any expression that
+ calls or takes the address of the function will have
+ pulled a FUNCTION_DECL out of the COMPONENT_REF. */
+ gcc_checking_assert (allow_non_constant);
+ *non_constant_p = true;
+ return t;
+ }
r = cxx_eval_component_reference (call, t, allow_non_constant, addr,
non_constant_p, overflow_p);
break;
===================================================================
@@ -0,0 +1,11 @@
+// PR c++/58647
+
+struct A
+{
+ static void foo();
+};
+
+template<typename> void bar()
+{
+ A().foo;
+}