From patchwork Wed Jul 24 19:54:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1964484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hPNcY5Hn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTl9z2PPLz1yXx for ; Thu, 25 Jul 2024 05:55:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69DE0385841D for ; Wed, 24 Jul 2024 19:55:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 869043858C31 for ; Wed, 24 Jul 2024 19:54:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 869043858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 869043858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721850873; cv=none; b=fc8h4n65LojYvPI58nbXASjfQmzd9VaZ9+4PaaszI/ljOZr7wPJmZT+nh/ka3+6qaPLuHh4h+sq0huTa633urbs1ieYbhxqBQew0r0hu2kEa+5+7ZWodnOntu4UGmfD0aAx4Eukm1KEhbdjmom+xpijf0zF/6urNVtdnQDQ35A0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721850873; c=relaxed/simple; bh=IaiG7ko8a+nTZfyC5eLGeVcXKPE6hvAeyKpxr66Jh5Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cYIdS60V/731S4II+XyGopO1lJSbStDLkcR7NeAtwSRyLZ8JERTC4LnXzUSHsx9I1XMG+Ib5Z8Gv4W6k5XKbBl+7wSSNZge7HTQ+8OBXu6RvSfphnJukumcwlXjQGjCAIkuTD8THFDcPbGhXkaSdDJbQYBD1QkmVrXH6qoF3jj4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721850871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d6sFMK6q0mAs13oashnHJ5EH8M056h5+t3C79jzIiSk=; b=hPNcY5Hn+ZXzjuN8ROSEOr8G1dk9uq+xTmn0f3B1AeZ+99DoB3E3CkNNi9rWDNj6BBcIZJ j+9Dkc3kWus0CFkHgcP4/sCYunYaLNs9HNGgrL0YovMrejHFqsHtXAcPeKpGqU6tLPQOQR ULTSwsZv1WAEIuvzYBgXYixrUNWm5Hc= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-4rmYCvLnNIC_dg2rRb-aig-1; Wed, 24 Jul 2024 15:54:29 -0400 X-MC-Unique: 4rmYCvLnNIC_dg2rRb-aig-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 039A41955F43; Wed, 24 Jul 2024 19:54:27 +0000 (UTC) Received: from localhost (unknown [10.42.28.14]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F68D3000192; Wed, 24 Jul 2024 19:54:25 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Add noexcept to bad_expected_access members (LWG 4031) Date: Wed, 24 Jul 2024 20:54:12 +0100 Message-ID: <20240724195424.4008093-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux. -- >8 -- libstdc++-v3/ChangeLog: * include/std/expected (bad_expected_access): Add noexcept to special member functions, as per LWG 4031. * testsuite/20_util/expected/bad.cc: Check for nothrow copy and move members. --- libstdc++-v3/include/std/expected | 8 ++++---- libstdc++-v3/testsuite/20_util/expected/bad.cc | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected index 2594cfe131c..3c52f7db01e 100644 --- a/libstdc++-v3/include/std/expected +++ b/libstdc++-v3/include/std/expected @@ -79,10 +79,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { protected: bad_expected_access() noexcept { } - bad_expected_access(const bad_expected_access&) = default; - bad_expected_access(bad_expected_access&&) = default; - bad_expected_access& operator=(const bad_expected_access&) = default; - bad_expected_access& operator=(bad_expected_access&&) = default; + bad_expected_access(const bad_expected_access&) noexcept = default; + bad_expected_access(bad_expected_access&&) noexcept = default; + bad_expected_access& operator=(const bad_expected_access&) noexcept = default; + bad_expected_access& operator=(bad_expected_access&&) noexcept = default; ~bad_expected_access() = default; public: diff --git a/libstdc++-v3/testsuite/20_util/expected/bad.cc b/libstdc++-v3/testsuite/20_util/expected/bad.cc index c629e149da5..7e227f904a0 100644 --- a/libstdc++-v3/testsuite/20_util/expected/bad.cc +++ b/libstdc++-v3/testsuite/20_util/expected/bad.cc @@ -12,3 +12,16 @@ test_pr105146() { std::bad_expected_access(E{}); } + +void +test_lwg4031() +{ + struct test_type : std::bad_expected_access { }; + + static_assert( std::is_nothrow_default_constructible_v ); + // LWG 4031. bad_expected_access member functions should be noexcept + static_assert( std::is_nothrow_copy_constructible_v ); + static_assert( std::is_nothrow_move_constructible_v ); + static_assert( std::is_nothrow_copy_assignable_v ); + static_assert( std::is_nothrow_move_assignable_v ); +}