From patchwork Mon Jul 8 19:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1958103 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=ISbfHDNG; 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 4WHvdh6gt5z1xpP for ; Tue, 9 Jul 2024 05:42:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 446A6395248A for ; Mon, 8 Jul 2024 19:41:58 +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 834FD392CA99 for ; Mon, 8 Jul 2024 19:41:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 834FD392CA99 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 834FD392CA99 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=1720467696; cv=none; b=VI5tyIHJpQmyLZTM6M9CZNHetOmq9RHF6ZlJ/VvrsthE3mQIX1r6oX2K+T2oaM6sOYAGncTV6QTz2CNdtmppS+jkArYyJvmXREcBNt/CCgs2nziDvVrWYI9ENEpn3QPWu9z8qMhUyuZgGUrHPTbO3s9QJoEKmfPMpFDvzGpg0NY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720467696; c=relaxed/simple; bh=S5ZAhdaWD3RR2eazrG5GuAp/xgwxr/ovo6rsWXxf/TE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k9FCMT4yLdngjpyYpKcdkrCzCsJU4qfHiOLKQyzLiFxbuq7OagtPGijr1MA3ezEgARjVqsOTJvUJIPJAXjO/+qsBWTNfBN9HJkVrbIigO0O4ToKb6ENTSplpG0l6/49EfD6Zm4WvKBdoVTH4ZP8k4mvADQH/MjfXcINAHmfNjFQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720467692; 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=UskU4V+W4WyR2WqLzLa/0fXbFuUew9kShDWX/rA8NE8=; b=ISbfHDNGKK1FIQxrlIP1OXSjC9d7VBBBkAIDjkLZjPFJ0hT0fBFWy41Gy7XxdNoQ4raWMA SPTEFqzNryJVB/kqa/YLknj+S+7yb6pIgkun1qwOJrJ+DpVk4fCGDaBNicoBtzhgFE0x+T k9uDH3fj6xRJ5n1m9/AICYowwg9B3Fg= Received: from mx-prod-mc-03.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-364-se3V9fgZMG6hLtjn1QLuIg-1; Mon, 08 Jul 2024 15:41:29 -0400 X-MC-Unique: se3V9fgZMG6hLtjn1QLuIg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 068DF1955BCC; Mon, 8 Jul 2024 19:41:28 +0000 (UTC) Received: from localhost (unknown [10.42.28.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 77089195605F; Mon, 8 Jul 2024 19:41:26 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix _Atomic(T) macro in [PR115807] Date: Mon, 8 Jul 2024 20:41:06 +0100 Message-ID: <20240708194124.491509-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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, 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. This should be backported too. -- >8 -- The definition of the _Atomic(T) macro needs to refer to ::std::atomic, not some other std::atomic relative to the current namespace. libstdc++-v3/ChangeLog: PR libstdc++/115807 * include/c_compatibility/stdatomic.h (_Atomic): Ensure it refers to std::atomic in the global namespace. * testsuite/29_atomics/headers/stdatomic.h/115807.cc: New test. --- libstdc++-v3/include/c_compatibility/stdatomic.h | 2 +- .../29_atomics/headers/stdatomic.h/115807.cc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc diff --git a/libstdc++-v3/include/c_compatibility/stdatomic.h b/libstdc++-v3/include/c_compatibility/stdatomic.h index 5403b52a036..72b9446eb17 100644 --- a/libstdc++-v3/include/c_compatibility/stdatomic.h +++ b/libstdc++-v3/include/c_compatibility/stdatomic.h @@ -35,7 +35,7 @@ #ifdef __cpp_lib_stdatomic_h // C++ >= 23 #include -#define _Atomic(_Tp) std::atomic<_Tp> +#define _Atomic(_Tp) ::std::atomic<_Tp> using std::memory_order; using std::memory_order_relaxed; diff --git a/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc new file mode 100644 index 00000000000..14f320fe835 --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/headers/stdatomic.h/115807.cc @@ -0,0 +1,14 @@ +// { dg-do compile { target c++23 } } +#include +namespace other { + namespace std { + int atomic = 0; + } + _Atomic(long) a{}; +} + +#include + +namespace non::std { + static_assert( ::std::is_same_v<_Atomic(int), ::std::atomic> ); +}