https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121858
Bug ID: 121858 Summary: function_ref(nontype_t<__fn>, _Up&& __ref) did not consider that _Up is a reference_wrapper Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- This constructor invokes the member pointer on a pointer to object _Up when _Fn is a member pointer. However, _Up can be a std::reference_wrapper because std::invoke supports wrapping objects with std::ref. In this case, the call is ill-formed. The following case is valid and should print hello: #include <functional> struct S { void f(); }; int main() { S s; auto sr = std::ref(s); std::function_ref<void()> fr(std::nontype<&S::f>, sr); fr(); } https://godbolt.org/z/4P1Eo17oj