https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114394
Bug ID: 114394 Summary: std::bind uses std::result_of which is deprecated Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: romain.geissler at amadeus dot com Target Milestone: --- Created attachment 57738 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57738&action=edit Tentative patch Hi, Clang >= 18 now prints a valid deprecation warning with this snippet: #include <functional> void f(); void g() { std::function<void()> a = std::bind(&f); } Warning: In file included from <source>:1: /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/functional:552:2: warning: 'result_of<void (*&())()>' is deprecated: use 'std::invoke_result' instead [-Wdeprecated-declarations] 552 | using _Res_type_impl | ^ /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/functional:556:2: note: in instantiation of template type alias '_Res_type_impl' requested here 556 | using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>; | ^ /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/functional:586:28: note: in instantiation of template type alias '_Res_type' requested here 586 | typename _Result = _Res_type<tuple<_Args...>>> | ^ <source>:7:31: note: in instantiation of template class 'std::_Bind<void (*())()>' requested here 7 | std::function<void()> a = std::bind(&f); | ^ /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/type_traits:2590:9: note: 'result_of<void (*&())()>' has been explicitly marked deprecated here 2590 | { } _GLIBCXX17_DEPRECATED_SUGGEST("std::invoke_result"); | ^ /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-linux-gnu/bits/c++config.h:122:45: note: expanded from macro '_GLIBCXX17_DEPRECATED_SUGGEST' 122 | # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) | ^ /opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-linux-gnu/bits/c++config.h:98:19: note: expanded from macro '_GLIBCXX_DEPRECATED_SUGGEST' 98 | __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) | ^ 1 warning generated. Compiler returned: 0 (see on Compiler Explorer: https://godbolt.org/z/3jxGr77Ye). I tried very quickly the attached patch, which seems to fix the warning for me (however I didn't really test it, so maybe it's not correct). Note: I guess the fix will qualify for a backport in releases branches, in my case I have hit this with gcc 13.