From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663359689; 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=3/AvZCt9BHdQ1UJ1oxnM2WbDrkZlvvXmiR8Qw8ufU10=; b=Srw5Q8uZ+LahpZT0nB/HMDzbF31MQ8vG7hXMUt/TP/qErhFC3Qav/91Ph/8wFpXJJHsWRY f2ED/mH1oqxpWMFuvFys2B08Tfb5silW8vO9nVGeGZm3DcNs50NAyFpY7EyKZFNdJfj8Sd xtWejN6+167ClAesAP/uRXBh81/5lYA= 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) From: Jonathan Wakely 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 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.37.3