public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated
@ 2024-03-19 13:52 romain.geissler at amadeus dot com
  2024-03-19 13:54 ` [Bug libstdc++/114394] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: romain.geissler at amadeus dot com @ 2024-03-19 13:52 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114394] std::bind uses std::result_of which is deprecated
  2024-03-19 13:52 [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated romain.geissler at amadeus dot com
@ 2024-03-19 13:54 ` redi at gcc dot gnu.org
  2024-03-19 13:57 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-19 13:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114394

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Patches need to be sent to the mailing list not attached in bugzilla.

The patch is wrong though, it needs to use _Fn& as an lvalue, not an rvalue.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114394] std::bind uses std::result_of which is deprecated
  2024-03-19 13:52 [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated romain.geissler at amadeus dot com
  2024-03-19 13:54 ` [Bug libstdc++/114394] " redi at gcc dot gnu.org
@ 2024-03-19 13:57 ` redi at gcc dot gnu.org
  2024-03-22 22:44 ` cvs-commit at gcc dot gnu.org
  2024-03-22 22:55 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-19 13:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114394

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Last reconfirmed|                            |2024-03-19
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh I see it's just a suggested change not a complete patch anyway. I'll take
care of this then. Thanks for the suggested patch at least :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114394] std::bind uses std::result_of which is deprecated
  2024-03-19 13:52 [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated romain.geissler at amadeus dot com
  2024-03-19 13:54 ` [Bug libstdc++/114394] " redi at gcc dot gnu.org
  2024-03-19 13:57 ` redi at gcc dot gnu.org
@ 2024-03-22 22:44 ` cvs-commit at gcc dot gnu.org
  2024-03-22 22:55 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-22 22:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114394

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:31ef58b18da930b09ea0dfc1d6533c5ef97d8446

commit r14-9632-g31ef58b18da930b09ea0dfc1d6533c5ef97d8446
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Mar 19 14:02:06 2024 +0000

    libstdc++: Replace std::result_of with __invoke_result_t [PR114394]

    Replace std::result_of with std::invoke_result, as specified in the
    standard since C++17, to avoid deprecated warnings for std::result_of.

    We don't have __invoke_result_t in C++11 mode, so add it as an alias
    template for __invoke_result<>::type (which is what std::result_of uses
    as its base class, so there's no change in functionality).

    This fixes warnings given by Clang 18.

    libstdc++-v3/ChangeLog:

            PR libstdc++/114394
            * include/std/functional (bind): Use __invoke_result_t instead
            of result_of::type.
            * include/std/type_traits (__invoke_result_t): New alias
            template.
            * testsuite/20_util/bind/ref_neg.cc: Adjust prune pattern.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/114394] std::bind uses std::result_of which is deprecated
  2024-03-19 13:52 [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated romain.geissler at amadeus dot com
                   ` (2 preceding siblings ...)
  2024-03-22 22:44 ` cvs-commit at gcc dot gnu.org
@ 2024-03-22 22:55 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-22 22:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114394

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-22 22:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 13:52 [Bug libstdc++/114394] New: std::bind uses std::result_of which is deprecated romain.geissler at amadeus dot com
2024-03-19 13:54 ` [Bug libstdc++/114394] " redi at gcc dot gnu.org
2024-03-19 13:57 ` redi at gcc dot gnu.org
2024-03-22 22:44 ` cvs-commit at gcc dot gnu.org
2024-03-22 22:55 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).