From patchwork Sat Jun 8 15:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1945500 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=HjBypmP1; 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 4VxM0K2YkPz20Q5 for ; Sun, 9 Jun 2024 01:08:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94429385F012 for ; Sat, 8 Jun 2024 15:08:47 +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 ESMTPS id 2AE213858C56 for ; Sat, 8 Jun 2024 15:08:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AE213858C56 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 2AE213858C56 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=1717859305; cv=none; b=PahnR7lbCz7SlwFfk92/FVOE8FJ24ikUxA5ULn6TJP8a8CdO4iNqZXefwO/CFnMCRnMR4mdKM/gczCAO3qXhF9WI8QD0V6nGjbsIpqKOpvD+EHJhhtTA8wma6jSZml/6P/4fj5u3NW3cOX7+UvSnNyluKLOKjPQpYKq4uuNv6+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717859305; c=relaxed/simple; bh=9r3/591yzsyoWNQpf8SsZs5KBXwLKxfvmnXRsJmuHus=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Eh/mGWOjD92v0R6AzXPFe81rBu9rMUgpIAwEkOLl1JdiEEsdtxLxc44+YWYr0kxrDb5IGItqHi2YtzsYhiVL3XNvlNB5d1vozsqaiqNq1pNMjeLQapzZY2lhSRz+9UpT9PVbneiRhfNo5req1UWWUmg6W8Lp/xkGTjQv+6+ipro= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717859303; 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: in-reply-to:in-reply-to:references:references; bh=ZXrHzYoLqhYd0aEvmVzTWPOXOmBiQnzXoV+cKyzezvU=; b=HjBypmP1EOLVHCJqUEwKVnhAfMP2eYRoZ2ZxKqlWczgL7g+EwaDJytGjbZJplurjF0atTa QqC6Ib4kGgjz0efj+jqzXL+bo1oqcvp+l/E5/QbOKgqthURA84bAUrCHiceO2LKP1qnBxg p3SkXRXNW3AiMQu/+KFdbHk//Gl0S7s= 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-665-AeSVb5raOzK_5nzFQl61Zg-1; Sat, 08 Jun 2024 11:08:22 -0400 X-MC-Unique: AeSVb5raOzK_5nzFQl61Zg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 2EF6819560AD; Sat, 8 Jun 2024 15:08:21 +0000 (UTC) Received: from localhost (unknown [10.39.192.128]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 434971956089; Sat, 8 Jun 2024 15:08:19 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed v2][libstdc++] Add constexpr specifier to function __atomic_impl::__clear_padding Date: Sat, 8 Jun 2024 16:07:00 +0100 Message-ID: <20240608150818.457672-1-jwakely@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.7 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, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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 Here's what I pushed to trunk, using the macro instead of the plain keyword, and with a testcase. Thanks for the patch, Deev. Tested x86_64-linux. Pushed to trunk. I'll backport this too. -- >8 -- This is called from the std::atomic constructor, which needs to be usable in constant expressions. libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_impl::__clear_padding): Add missing constexpr specifier. * testsuite/29_atomics/atomic_float/constinit.cc: New test. Co-authored-by: Jonathan Wakely --- libstdc++-v3/include/bits/atomic_base.h | 2 +- libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 062f1549740..20901b7fc06 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -968,7 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - _GLIBCXX_ALWAYS_INLINE _Tp* + _GLIBCXX_ALWAYS_INLINE _GLIBCXX14_CONSTEXPR _Tp* __clear_padding(_Tp& __val) noexcept { auto* __ptr = std::__addressof(__val); diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc new file mode 100644 index 00000000000..6b3f4f76b4c --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc @@ -0,0 +1,3 @@ +// { dg-do compile { target c++20 } } +#include +constinit std::atomic a(0.0f);