public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10303] libstdc++: Improve std::forward static assert message Date: Fri, 26 Nov 2021 15:41:08 +0000 (GMT) [thread overview] Message-ID: <20211126154108.A70A13857C70@sourceware.org> (raw) https://gcc.gnu.org/g:453a8f3d3966f024fae8b8bb40f968e4be2b458e commit r10-10303-g453a8f3d3966f024fae8b8bb40f968e4be2b458e Author: Jonathan Wakely <jwakely@redhat.com> 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 <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/move.h (forward(remove_reference_t<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 5a4dbdc823c..b5a4020eeee 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -86,8 +86,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 is 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 8b6736d42f0..5e318ed67f4 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 // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 89 } +// { dg-error "convert an rvalue to an lvalue" "" { target *-*-* } 0 } #include <list> diff --git a/libstdc++-v3/testsuite/20_util/forward/f_neg.cc b/libstdc++-v3/testsuite/20_util/forward/f_neg.cc index 4b697f1cd5d..c6cf880bd15 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 // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 89 } +// { dg-error "convert an rvalue to an lvalue" "" { target *-*-* } 0 } #include <utility>
reply other threads:[~2021-11-26 15:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211126154108.A70A13857C70@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).