[committed] libstdc++: Allow exception classes to move fully-dynamic strings

Message ID 20211202165748.366733-1-jwakely@redhat.com
State Committed
Commit acf4fe96f12341da253fa9a932947581690122a4
Headers
Series [committed] libstdc++: Allow exception classes to move fully-dynamic strings |

Commit Message

Jonathan Wakely Dec. 2, 2021, 4:57 p.m. UTC
  Tested powerpc64le-linux using --enable-fully-dynamic-string and
x86_64-linux using the default config. Pushed to trunk.


The move constructor for the fully-dynamic std::basic_string was not
noexcept until recently, so the std::logic_error and std::runtime_error
move constructors were defined to make non-throwing copies of their
string members, instead of potentially-throwing moves.

Now that move construction is always noexecpt, the exception classes can
always move the string. The fully-dynamic string move assignment was
always noexcept, so I don't know why I special-cased the move assignment
operators of the exception classes. That can be changed too.

libstdc++-v3/ChangeLog:

	* src/c++11/cow-stdexcept.cc [_GLIBCXX_FULY_DYNAMIC_STRING]
	(logic_error, runtime_error): Remove custom definitions.
---
 libstdc++-v3/src/c++11/cow-stdexcept.cc | 20 --------------------
 1 file changed, 20 deletions(-)
  

Patch

diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 751c3302303..2d47acb55b2 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -57,8 +57,6 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // These operations are noexcept even though copying a COW string is not,
   // but we know that the string member in an exception has not been "leaked"
   // so copying is a simple reference count increment.
-  // For the fully dynamic string moves are not noexcept (due to needing to
-  // allocate an empty string) so we just define the moves as copies here.
 
   logic_error::logic_error(const logic_error& e) noexcept
   : exception(e), _M_msg(e._M_msg) { }
@@ -66,19 +64,10 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   logic_error& logic_error::operator=(const logic_error& e) noexcept
   { _M_msg = e._M_msg; return *this; }
 
-#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
   logic_error::logic_error(logic_error&& e) noexcept = default;
 
   logic_error&
   logic_error::operator=(logic_error&& e) noexcept = default;
-#else
-  logic_error::logic_error(logic_error&& e) noexcept
-  : exception(e), _M_msg(e._M_msg) { }
-
-  logic_error&
-  logic_error::operator=(logic_error&& e) noexcept
-  { _M_msg = e._M_msg; return *this; }
-#endif
 
   runtime_error::runtime_error(const runtime_error& e) noexcept
   : exception(e), _M_msg(e._M_msg) { }
@@ -87,19 +76,10 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   runtime_error::operator=(const runtime_error& e) noexcept
   { _M_msg = e._M_msg; return *this; }
 
-#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
   runtime_error::runtime_error(runtime_error&& e) noexcept = default;
 
   runtime_error&
   runtime_error::operator=(runtime_error&& e) noexcept = default;
-#else
-  runtime_error::runtime_error(runtime_error&& e) noexcept
-  : exception(e), _M_msg(e._M_msg) { }
-
-  runtime_error&
-  runtime_error::operator=(runtime_error&& e) noexcept
-  { _M_msg = e._M_msg; return *this; }
-#endif
 
   // New C++11 constructors: