public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails
@ 2021-08-11 19:41 seurer at gcc dot gnu.org
  2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: seurer at gcc dot gnu.org @ 2021-08-11 19:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

            Bug ID: 101866
           Summary: libstdc++-v3/testsuite/experimental/random/randint.cc
                    fails
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: seurer at gcc dot gnu.org
  Target Milestone: ---

libstdc++-v3/testsuite/experimental/random/randint.cc fails on rare occasions. 
I have only seen it happen twice now once after running it 1.9 million times to
try to spot it:

/home/seurer/gcc/git/gcc-9-test/libstdc++-v3/testsuite/experimental/random/randint.cc:61:
void test01(): Assertion '!(n3[0] == n1[0] && n3[1] == n1[1] && n3[2] ==
n1[2])' failed.
/home/seurer/bin/runmany.gcc: line 212: 39222 Aborted                 (core
dumped) ./randint.exe

While I spotted this with gcc 9 the test has not changed in current trunk anmd
I assume in gcc 10 and gcc 11 as well.

OK,

  std::experimental::reseed(99u);
  const long n1[] = {
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100)
  };
. . .
  std::experimental::reseed();
  const long n3[] = {
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100)
  };
  VERIFY( !(n3[0] == n1[0] && n3[1] == n1[1] && n3[2] == n1[2]) );

I don't think the above code from the test is correct.  There is a small chance
(1 in 100 for each) that the values in n3 will be the same as the values in n1.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-11 22:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
2021-08-11 19:51 ` redi at gcc dot gnu.org
2021-08-11 19:51 ` redi at gcc dot gnu.org
2021-08-11 22:46 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:46 ` redi at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:54 ` redi at gcc dot gnu.org

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