From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id F33303858425; Wed, 24 Nov 2021 11:50:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F33303858425 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9280] libstdc++: Improve std::forward static assert message X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 24449ffb08513e9c70e20ea556d1a413a50580ae X-Git-Newrev: dda6b9ce0f80ae82b94efa0abed941d879489d95 Message-Id: <20211124115031.F33303858425@sourceware.org> Date: Wed, 24 Nov 2021 11:50:31 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2021 11:50:32 -0000 https://gcc.gnu.org/g:dda6b9ce0f80ae82b94efa0abed941d879489d95 commit r11-9280-gdda6b9ce0f80ae82b94efa0abed941d879489d95 Author: Jonathan Wakely Date: Tue Sep 28 12:35:29 2021 +0100 libstdc++: Improve std::forward static assert message The previous message told you something was wrong, but not why it happened or why it's bad. This changes it to explain that the function is being misused. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/move.h (forward(remove_reference_t&&)): Improve text of static_assert. * testsuite/20_util/forward/c_neg.cc: Adjust dg-error. * testsuite/20_util/forward/f_neg.cc: Likewise. (cherry picked from commit a11052d98db2f2a61841f0c5ee84de4ca1b3e296) Diff: --- libstdc++-v3/include/bits/move.h | 4 ++-- libstdc++-v3/testsuite/20_util/forward/c_neg.cc | 2 +- libstdc++-v3/testsuite/20_util/forward/f_neg.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index 3abbb37ceeb..2dd7ed9e4f9 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -88,8 +88,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) noexcept { - static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument" - " substituting _Tp must not be an lvalue reference type"); + static_assert(!std::is_lvalue_reference<_Tp>::value, + "std::forward must not be used to convert an rvalue to an lvalue"); return static_cast<_Tp&&>(__t); } diff --git a/libstdc++-v3/testsuite/20_util/forward/c_neg.cc b/libstdc++-v3/testsuite/20_util/forward/c_neg.cc index dc7ec51bde6..3875792866e 100644 --- a/libstdc++-v3/testsuite/20_util/forward/c_neg.cc +++ b/libstdc++-v3/testsuite/20_util/forward/c_neg.cc @@ -17,7 +17,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "must not be an lvalue reference" "" { target *-*-* } 0 } +// { dg-error "convert an rvalue to an lvalue" "" { target *-*-* } 0 } #include diff --git a/libstdc++-v3/testsuite/20_util/forward/f_neg.cc b/libstdc++-v3/testsuite/20_util/forward/f_neg.cc index 4ccd7264c65..51ccaf29c1a 100644 --- a/libstdc++-v3/testsuite/20_util/forward/f_neg.cc +++ b/libstdc++-v3/testsuite/20_util/forward/f_neg.cc @@ -17,7 +17,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "must not be an lvalue reference" "" { target *-*-* } 0 } +// { dg-error "convert an rvalue to an lvalue" "" { target *-*-* } 0 } #include