public inbox for
 help / color / mirror / Atom feed
From: Eric Botcazou <>
To: Jonathan Wakely <>
Subject: Re: [committed] libstdc++: Fix test for std::atomic_ref
Date: Mon, 31 Oct 2022 16:34:27 +0100	[thread overview]
Message-ID: <5772422.MhkbZ0Pkbq@fomalhaut> (raw)
In-Reply-To: <>

> 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.

The tests fail randomly for me on SPARC64/Linux:

FAIL: 29_atomics/atomic/ execution test
FAIL: 29_atomics/atomic_ref/ execution test

/home/ebotcazou/src/libstdc++-v3/testsuite/29_atomics/atomic_ref/ int main(): Assertion 'compare_struct(ts, es)' 
FAIL: 29_atomics/atomic_ref/ execution test

  std::atomic<S> as{ s };
  auto ts = as.load();
  VERIFY( !compare_struct(s, ts) ); // padding cleared on construction;
  auto es = as.load();
  VERIFY( compare_struct(ts, es) ); // padding cleared on exchange

How is it supposed to pass exactly?  AFAICS you have no control on the padding 
bits of ts or es and, indeed, at -O2 the loads are scalarized:

  __buf$c_81 = MEM[(struct S *)&__buf].c;
  __buf$s_59 = MEM[(struct S *)&__buf].s;
  __buf ={v} {CLOBBER(eol)};
  ts.c = __buf$c_81;
  ts.s = __buf$s_59;
  __buf$c_100 = MEM[(struct S *)&__buf].c;
  __buf$s_35 = MEM[(struct S *)&__buf].s;
  __buf ={v} {CLOBBER(eol)};
  es.c = __buf$c_100;
  es.s = __buf$s_35;
  _66 = MEM <unsigned int> [(char * {ref-all})&ts];
  _101 = MEM <unsigned int> [(char * {ref-all})&es];
  if (_66 != _101)
    goto <bb 5>; [0.04%]
    goto <bb 6>; [99.96%]

so the result of the 4-byte comparison is random.

Eric Botcazou

  reply	other threads:[~2022-10-31 15:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 20:21 Jonathan Wakely
2022-10-31 15:34 ` Eric Botcazou [this message]
2022-10-31 15:37   ` Jonathan Wakely
2022-10-31 17:03     ` Eric Botcazou
2022-10-31 17:05       ` Jonathan Wakely
2022-11-01 13:53         ` Jonathan Wakely
2022-11-01 15:26           ` Eric Botcazou
2023-09-01 15:21   ` Jonathan Wakely
2023-09-01 18:14     ` Eric Botcazou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5772422.MhkbZ0Pkbq@fomalhaut \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).