From patchwork Thu Aug 16 15:56:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 958451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483786-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="akpKwkdZ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rrY126jZz9s3Z for ; Fri, 17 Aug 2018 01:56:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=dT0HrzkEGpx6NW8yGx/LByIT6uFpNSD4x6zDOYEwdHdx9TZtZW44b jUMHpxgB+wHBdRHi6qo8e86rbd0PC/2MyRrPMBsFXxs+v74AqBlwwc41Ct3ffRil PfDukkiYCtIQ7gAXAyIVma28fUgeEnPhkSYW0LnqqslnNmfJBvZERw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=mlvRBl4IyiR2L1EL/mFvHN7sxJQ=; b=akpKwkdZfxCICpaNlIXX mnjjYKNn++PjxT2yHrQX1HivSm4WVJru0SppvPeRhW11aQ3ar4RV1RcxWJ1Sx7oo BR9dWSbXdFuy7I8iQXT79X0WZGYj748MK6vZBymL0APj1HHefRrGJ2A4gX94AaEr kqI9mRR6My8eDvxYjPbhmUE= Received: (qmail 27024 invoked by alias); 16 Aug 2018 15:56:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27005 invoked by uid 89); 16 Aug 2018 15:56:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=leaked X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Aug 2018 15:56:11 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5A13401EF3C; Thu, 16 Aug 2018 15:56:09 +0000 (UTC) Received: from localhost (unknown [10.33.36.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 782152027047; Thu, 16 Aug 2018 15:56:09 +0000 (UTC) Date: Thu, 16 Aug 2018 16:56:08 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Fix bootstrap with --enable-fully-dynamic-string Message-ID: <20180816155608.GA22970@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.2 (2017-12-15) PR libstdc++/86447 * src/c++11/cow-stdexcept.cc [_GLIBCXX_FULLY_DYNAMIC_STRING] (logic_error::logic_error(logic_error&&)) (logic_error::operator=(logic_error&&)) (runtime_error::runtime_error(runtime_error&&)) (runtime_error::operator=(runtime_error&&)): Copy strings instead of moving, to avoid allocating empty reps for moved-from strings. Tested x86_64-linux, committed to trunk. commit b06d2a88c3ea36c41c370cf95730d54f764b9f47 Author: Jonathan Wakely Date: Thu Aug 16 15:31:40 2018 +0100 Fix bootstrap with --enable-fully-dynamic-string PR libstdc++/86447 * src/c++11/cow-stdexcept.cc [_GLIBCXX_FULLY_DYNAMIC_STRING] (logic_error::logic_error(logic_error&&)) (logic_error::operator=(logic_error&&)) (runtime_error::runtime_error(runtime_error&&)) (runtime_error::operator=(runtime_error&&)): Copy strings instead of moving, to avoid allocating empty reps for moved-from strings. diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc index 54859d58820..d271be529a6 100644 --- a/libstdc++-v3/src/c++11/cow-stdexcept.cc +++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc @@ -57,6 +57,8 @@ _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) { } @@ -64,10 +66,19 @@ _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) { } @@ -76,10 +87,19 @@ _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: