From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Fix fully-dynamic-string build
Date: Tue, 30 Nov 2021 23:11:18 +0000 [thread overview]
Message-ID: <20211130231118.154198-1-jwakely@redhat.com> (raw)
Tested powerpc64le-linux (old ABI) and x86_64-linux (new ABI), pushed to
trunk.
My last change to the fully-dynamic-string actually broke it. This fixes
the move constructor so it builds, and simplifies it slightly so that
more code is common between the fully-dynamic enabled/disabled cases.
libstdc++-v3/ChangeLog:
* include/bits/cow_string.h (basic_string(basic_string&&)): Fix
mem-initializer for _GLIBCXX_FULLY_DYNAMIC_STRING==0 case.
* testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc:
Remove outdated comment.
* testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc:
Likewise.
---
libstdc++-v3/include/bits/cow_string.h | 8 +++-----
.../basic_string/cons/char/noexcept_move_construct.cc | 1 -
.../basic_string/cons/wchar_t/noexcept_move_construct.cc | 1 -
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index bafca7bb313..ced395b80b8 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -621,14 +621,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @a __str is a valid, but unspecified string.
*/
basic_string(basic_string&& __str) noexcept
-#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
: _M_dataplus(std::move(__str._M_dataplus))
{
+#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
+ // Make __str use the shared empty string rep.
__str._M_data(_S_empty_rep()._M_refdata());
- }
#else
- : _M_dataplus(__str._M_rep())
- {
// Rather than allocate an empty string for the rvalue string,
// just share ownership with it by incrementing the reference count.
// If the rvalue string was "leaked" then it was the unique owner,
@@ -637,8 +635,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__gnu_cxx::__atomic_add_dispatch(&_M_rep()->_M_refcount, 2);
else
__gnu_cxx::__atomic_add_dispatch(&_M_rep()->_M_refcount, 1);
- }
#endif
+ }
/**
* @brief Construct string from an initializer %list.
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc
index f04a491370d..74b0ed3910c 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/noexcept_move_construct.cc
@@ -23,7 +23,6 @@
typedef std::string stype;
-// True except for COW strings with _GLIBCXX_FULLY_DYNAMIC_STRING:
static_assert(std::is_nothrow_move_constructible<stype>::value, "Error");
// True for std::allocator because is_always_equal, but not true in general:
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc
index d5dbf561ec0..53cb81d8aee 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/noexcept_move_construct.cc
@@ -23,7 +23,6 @@
typedef std::wstring wstype;
-// True except for COW strings with _GLIBCXX_FULLY_DYNAMIC_STRING:
static_assert(std::is_nothrow_move_constructible<wstype>::value, "Error");
// True for std::allocator because is_always_equal, but not true in general:
--
2.31.1
reply other threads:[~2021-11-30 23:11 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=20211130231118.154198-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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: link
Be 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).