From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C8F7F3857B80; Wed, 28 Sep 2022 23:36:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8F7F3857B80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664408196; bh=aoO8RZ2l0uXjbvfFtXp1WQjh66WeeSQ7r5Frgi79rl4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XDCSc7MLaJAJaTagICwzeoivUUkKExlEkHiG+scrXXTIcuVeq+eQP53WR8jlQrsaU lMjYnyKFxvJbm5QHwaeekOX02oq4vPTbqSqfX1cwWH9DllN3paRI2adQMTvD2LU3Z7 YM7RTgAH7PkNujQxDdYDD5qDJO3TC2wv3Z6xVJk0= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/70692] No warning when std::function binds a reference to a temporary Date: Wed, 28 Sep 2022 23:35:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D70692 --- Comment #7 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:fa9bda3ea4315a7285edbc99323e3fa7885cbbb8 commit r13-2922-gfa9bda3ea4315a7285edbc99323e3fa7885cbbb8 Author: Jonathan Wakely Date: Tue Sep 27 20:59:05 2022 +0100 libstdc++: Make INVOKE refuse to create dangling references [PR70692] This is the next part of the library changes from P2255R2. This makes INVOKE 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 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 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 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.=