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 r12-5755] libstdc++: Allow exception classes to move fully-dynamic strings
Date: Thu,  2 Dec 2021 16:53:52 +0000 (GMT)	[thread overview]
Message-ID: <20211202165352.20284385BF85@sourceware.org> (raw)

https://gcc.gnu.org/g:acf4fe96f12341da253fa9a932947581690122a4

commit r12-5755-gacf4fe96f12341da253fa9a932947581690122a4
Author: Jonathan Wakely <jwakely@redhat.com>
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:


                 reply	other threads:[~2021-12-02 16:53 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=20211202165352.20284385BF85@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: 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).