From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 20284385BF85; Thu, 2 Dec 2021 16:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20284385BF85 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 r12-5755] libstdc++: Allow exception classes to move fully-dynamic strings X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: e2e98f524fdb80c16e3395f20fee930fbcad5562 X-Git-Newrev: acf4fe96f12341da253fa9a932947581690122a4 Message-Id: <20211202165352.20284385BF85@sourceware.org> Date: Thu, 2 Dec 2021 16:53:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 16:53:52 -0000 https://gcc.gnu.org/g:acf4fe96f12341da253fa9a932947581690122a4 commit r12-5755-gacf4fe96f12341da253fa9a932947581690122a4 Author: Jonathan Wakely Date: Thu Dec 2 11:53:21 2021 +0000 libstdc++: Allow exception classes to move fully-dynamic strings 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. Diff: --- libstdc++-v3/src/c++11/cow-stdexcept.cc | 20 -------------------- 1 file changed, 20 deletions(-) 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: