From patchwork Fri Sep 16 20:21:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp914592wrt; Fri, 16 Sep 2022 13:22:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4280t4fjefTki7h7pQ/vVYlFLdvQE42GPVAbLHPSAZyyw95wwkX1CzM4VGi0OKmCnGhJEq X-Received: by 2002:a17:907:1dcc:b0:77a:c5f3:708b with SMTP id og12-20020a1709071dcc00b0077ac5f3708bmr4759371ejc.331.1663359764517; Fri, 16 Sep 2022 13:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663359764; cv=none; d=google.com; s=arc-20160816; b=d1PT8jE01nn8kH3/+32bTUXuWFhcTarR8R/a3fmffW/p/Z/PlAqGunvuknOfQlaEEm 6+ngEqGbCDLNHQMPbcOo1ilKJJy8Fy4wjf1n7/yNIGbnE2IE9RsbU9fSP3xXEqlVIeNm z6NqYZY1l0bbnQObJx9QhlnI8lCfHTYY8s/270YVh5n32wTTh4XXHDwvU4Z+j6eN/e0R Y+k8NhNtBJgzEg0zdtekYatuIZTDJtoGOqG0Dpv+n4282uPPNmhuMOBnoZA6fWPwRbyu K6wNVQUNfImzMtdug8vtlXTuWKnFuHSoWVt4ILJ/7Qihi9h5aOUwq+3thrBNIkkmwWMA 17Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=3/AvZCt9BHdQ1UJ1oxnM2WbDrkZlvvXmiR8Qw8ufU10=; b=ZjRN7W5RBSzK+6SWaUG1/dBcO222an21nwoz0PNnQx/QbLVZFZGNt8UkCZQnWfrrU6 1rHle3HIrNgZdRXPYsNddYlyoc1mvLjU6azUKS9a1sTUkN09qvl23UF7YbMykp+A6sPq lgiAIfxDHsoe4IrGEAi2pknxFd4FXxtJ0GwT7tG47JFVsxMd2Xp0aJGgF1INFVCOuiJH M5WuPaoPQ2K6tRDEvNSFubofNCQS6aw80XrGUq8cywqrijGmxTll53vLpb8wmd4XElgr +leeHPt3wLWgVi6ZNsW6KGog2cP9k17wJ/CTmTEV6LETMRKKS7LlTKk9Xy7FXk3O0khr VaUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wbqo9w2M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hz3-20020a1709072ce300b007804b9e90d4si5830677ejc.45.2022.09.16.13.22.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 13:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wbqo9w2M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EFA03949087 for ; Fri, 16 Sep 2022 20:22:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EFA03949087 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663359738; bh=3/AvZCt9BHdQ1UJ1oxnM2WbDrkZlvvXmiR8Qw8ufU10=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wbqo9w2MjAwAc5D19HHIHZQhQQ/LtXuJBKtAJyqA1GNPBUti0yxkeim8M4q6u8HGp LRft1eoHGvNfCdvvGu6NbUDO2HV/N7+x83SjTqzuqva73WeVRcf7UtpYqXDgNdUCZ1 rRKZqZBsKR0sA2ulXTQwMPUwjyChw8YgOBS4ty5o= 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 2E8C238582AD for ; Fri, 16 Sep 2022 20:21:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E8C238582AD Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-qm8PIvdvPOikZTBwkZfe0A-1; Fri, 16 Sep 2022 16:21:28 -0400 X-MC-Unique: qm8PIvdvPOikZTBwkZfe0A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C0E8811E67; Fri, 16 Sep 2022 20:21:28 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15C091121314; Fri, 16 Sep 2022 20:21:27 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref Date: Fri, 16 Sep 2022 21:21:27 +0100 Message-Id: <20220916202127.579816-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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_LOW, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744159128463236303?= X-GMAIL-MSGID: =?utf-8?q?1744159128463236303?= Tested x86_64-linux, pushed to trunk. The test was only failing for me with -m32 (and not -m64), so I didn't notice until now. That probably means we should make the test fail more reliably if the padding isn't being cleared. -- >8 -- This test was written assuming that std::atomic_ref clears its target's padding on construction, but that could introduce data races. Change the test to store a value after construction and check that its padding is cleared by the store. libstdc++-v3/ChangeLog: * testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc: Store value with non-zero padding bits after construction. --- .../29_atomics/atomic_ref/compare_exchange_padding.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc index 1b1a12dddda..e9f8a4bdf2a 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc @@ -20,14 +20,15 @@ int main () { S s; - fill_struct(s); - s.c = 'a'; - s.s = 42; - S ss{ s }; + fill_struct(ss); + ss.c = 'a'; + ss.s = 42; + std::atomic_ref as{ s }; + as.store(ss); auto ts = as.load(); - VERIFY( !compare_struct(ss, ts) ); // padding cleared on construction + VERIFY( !compare_struct(ss, ts) ); // padding cleared on store as.exchange(ss); auto es = as.load(); VERIFY( compare_struct(ts, es) ); // padding cleared on exchange