From patchwork Wed Feb 28 14:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1905843 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=HdIAiYR8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4TlHQr1yzlz1yX2 for ; Thu, 29 Feb 2024 01:53:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50AE43858403 for ; Wed, 28 Feb 2024 14:53:05 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id 5E7B33858D39 for ; Wed, 28 Feb 2024 14:52:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E7B33858D39 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 5E7B33858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709131963; cv=none; b=W5K6M7T/BXtc5x468GFlfso3ea5G8f9EQXYRAANevvkJfrljL+Ua7Wd0sfVWE6O8xsbmIxagkksdtM6QwxKZfqhZ5rONnOF+Hbu13wwfYcRT42Kq3nuqn/cF+2++dSHYjI56R7oyyZQfccYCSwXDmFynntr1glvcmGE7P4D7Hxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709131963; c=relaxed/simple; bh=q20E0ExxBSiI/0YMylS4fPJakXEf5W+dE4eSurE++rM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cHmgwdE+YwV2cjgWwPn2A0tcqFO9Fv3Bj4YAG4Lg21NJ1Lu8BEguUxC4HYOxSPULhNkBghKJrdCwbGYZSshqTgquvla8H+GxteXYeKz8LRMZOapbpojTwl+6HF/8BLGwNJP3KvGqcfQSnt7pp0EZUeokToDjo8/MWATxE1etlbI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709131961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZRcj/o6/XoeCKrmtnef5wVQmeDbQKScggx1bTXBIKYg=; b=HdIAiYR8lxVjOMr4ZVJxzWZuunavcrPe/KGB2C5UfsakDTkyZ8FdHWdAPMET5iuwR8Ro/S 2+0QKTbHudttc4xU0oogzDDzqDctH0zLhfyzcENZQgOwOs2rVJu07+7fwDPX16r97x/0zi vSinmLTGZe15njy44zgzeMuhuGyJoFU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-378-37pGkLH1PLeVkGhJuuxqEA-1; Wed, 28 Feb 2024 09:52:36 -0500 X-MC-Unique: 37pGkLH1PLeVkGhJuuxqEA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id AED7B381258D; Wed, 28 Feb 2024 14:52:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 928132022AAC; Wed, 28 Feb 2024 14:52:34 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: __vic Subject: [committed] libstdc++: Fix noexcept on dtors in [PR114152] Date: Wed, 28 Feb 2024 14:51:48 +0000 Message-ID: <20240228145234.214146-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URI_HEX autolearn=unavailable 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, pushed to trunk. Backport to gcc-13 to follow. -- >8 -- The PR points out that the destructors all have incorrect noexcept-specifiers. libstdc++-v3/ChangeLog: PR libstdc++/114152 * include/experimental/scope (scope_exit scope_fail): Make destructor unconditionally noexcept. (scope_sucess): Fix noexcept-specifier. * testsuite/experimental/scopeguard/114152.cc: New test. --- libstdc++-v3/include/experimental/scope | 6 ++--- .../experimental/scopeguard/114152.cc | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 libstdc++-v3/testsuite/experimental/scopeguard/114152.cc diff --git a/libstdc++-v3/include/experimental/scope b/libstdc++-v3/include/experimental/scope index 5dbeac14795..ea273e8c095 100644 --- a/libstdc++-v3/include/experimental/scope +++ b/libstdc++-v3/include/experimental/scope @@ -97,7 +97,7 @@ namespace experimental::inline fundamentals_v3 scope_exit& operator=(const scope_exit&) = delete; scope_exit& operator=(scope_exit&&) = delete; - ~scope_exit() noexcept(noexcept(this->_M_exit_function)) + ~scope_exit() noexcept { if (_M_execute_on_destruction) _M_exit_function(); @@ -157,7 +157,7 @@ namespace experimental::inline fundamentals_v3 scope_fail& operator=(const scope_fail&) = delete; scope_fail& operator=(scope_fail&&) = delete; - ~scope_fail() noexcept(noexcept(this->_M_exit_function)) + ~scope_fail() noexcept { if (std::uncaught_exceptions() > _M_uncaught_init) _M_exit_function(); @@ -211,7 +211,7 @@ namespace experimental::inline fundamentals_v3 scope_success& operator=(const scope_success&) = delete; scope_success& operator=(scope_success&&) = delete; - ~scope_success() noexcept(noexcept(this->_M_exit_function)) + ~scope_success() noexcept(noexcept(this->_M_exit_function())) { if (std::uncaught_exceptions() <= _M_uncaught_init) _M_exit_function(); diff --git a/libstdc++-v3/testsuite/experimental/scopeguard/114152.cc b/libstdc++-v3/testsuite/experimental/scopeguard/114152.cc new file mode 100644 index 00000000000..63c1f710e9f --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/scopeguard/114152.cc @@ -0,0 +1,24 @@ +// { dg-do compile { target c++20 } } + +// PR libstdc++/114152 +// Wrong exception specifiers for LFTSv3 scope guard destructors + +#include + +using namespace std::experimental; + +struct F { + void operator()() noexcept(false); +}; + +static_assert( noexcept(std::declval&>().~scope_exit()) ); +static_assert( noexcept(std::declval&>().~scope_fail()) ); +static_assert( ! noexcept(std::declval&>().~scope_success()) ); + +struct G { + void operator()() noexcept(true); +}; + +static_assert( noexcept(std::declval&>().~scope_exit()) ); +static_assert( noexcept(std::declval&>().~scope_fail()) ); +static_assert( noexcept(std::declval&>().~scope_success()) );