public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
@ 2021-04-19 10:40 ` redi at gcc dot gnu.org
  2021-12-03 19:45 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|redi at gcc dot gnu.org            |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

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

* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
  2021-04-19 10:40 ` [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary redi at gcc dot gnu.org
@ 2021-12-03 19:45 ` pinskia at gcc dot gnu.org
  2021-12-03 22:12 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at hazlewoods dot net

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 103543 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
  2021-04-19 10:40 ` [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary redi at gcc dot gnu.org
  2021-12-03 19:45 ` pinskia at gcc dot gnu.org
@ 2021-12-03 22:12 ` redi at gcc dot gnu.org
  2022-02-09 20:04 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-03 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
"A type trait to detect reference binding to temporary"
https://wg21.link/p2255r2 is the current direction to resolve this.

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

* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-03 22:12 ` redi at gcc dot gnu.org
@ 2022-02-09 20:04 ` pinskia at gcc dot gnu.org
  2022-09-28 23:35 ` cvs-commit at gcc dot gnu.org
  2022-09-28 23:38 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-09 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=104477

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> "A type trait to detect reference binding to temporary"
> https://wg21.link/p2255r2 is the current direction to resolve this.

Which is now recorded as PR 104477.

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

* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-02-09 20:04 ` pinskia at gcc dot gnu.org
@ 2022-09-28 23:35 ` cvs-commit at gcc dot gnu.org
  2022-09-28 23:38 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-28 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS 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:fa9bda3ea4315a7285edbc99323e3fa7885cbbb8

commit r13-2922-gfa9bda3ea4315a7285edbc99323e3fa7885cbbb8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 27 20:59:05 2022 +0100

    libstdc++: Make INVOKE<R> refuse to create dangling references [PR70692]

    This is the next part of the library changes from P2255R2. This makes
    INVOKE<R> ill-formed if converting the INVOKE expression to R would bind
    a reference to a temporary object.

    The is_invocable_r trait is now false if the invocation would create a
    dangling reference. This is done by adding the dangling check to the
    __is_invocable_impl partial specialization used for INVOKE<R>
    expressions. This change also slightly simplifies the nothrow checking
    recently added to that partial specialization.

    This change also removes the is_invocable_r checks from the pre-C++17
    implementation of std::__invoke_r, because there is no need for it to be
    SFINAE-friendly. None of our C++11 and C++14 uses of INVOKE<R> require
    those constraints. The std::function constructor needs to check
    is_invocable_r, but that's already done explicitly, so we don't need to
    recheck when calling __is_invoke_r in std::function::operator(). The
    other uses of std::__is_invoke_r do not need to be constrained and can
    just be ill-formed if the INVOKE<R> expression is ill-formed.

    libstdc++-v3/ChangeLog:

            PR libstdc++/70692
            * include/bits/invoke.h [__cplusplus < 201703] (__invoke_r):
            Remove is_invocable and is_convertible constraints.
            * include/std/type_traits (__is_invocable_impl::_S_conv): Use
            non-deduced context for parameter.
            (__is_invocable_impl::_S_test): Remove _Check_noex template
            parameter and use deduced noexcept value in its place. Add bool
            parameter to detect dangling references.
            (__is_invocable_impl::type): Adjust call to _S_test to avoid
            deducing unnecessary noexcept property..
            (__is_invocable_impl::__nothrow_type): Rename to ...
            (__is_invocable_impl::__nothrow_conv): ... this. Adjust call
            to _S_test to deduce noexcept property.
            * testsuite/20_util/bind/dangling_ref.cc: New test.
            * testsuite/20_util/function/cons/70692.cc: New test.
            * testsuite/20_util/function_objects/invoke/dangling_ref.cc:
            New test.
            * testsuite/20_util/is_invocable/dangling_ref.cc: New test.
            * testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
            New test.

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

* [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary
       [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-09-28 23:35 ` cvs-commit at gcc dot gnu.org
@ 2022-09-28 23:38 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-28 23:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 13 by implementing the changes from https://wg21.link/P2255R2

The original example is now ill-formed.

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

end of thread, other threads:[~2022-09-28 23:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-70692-4@http.gcc.gnu.org/bugzilla/>
2021-04-19 10:40 ` [Bug libstdc++/70692] No warning when std::function<const int&(...)> binds a reference to a temporary redi at gcc dot gnu.org
2021-12-03 19:45 ` pinskia at gcc dot gnu.org
2021-12-03 22:12 ` redi at gcc dot gnu.org
2022-02-09 20:04 ` pinskia at gcc dot gnu.org
2022-09-28 23:35 ` cvs-commit at gcc dot gnu.org
2022-09-28 23:38 ` 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).