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.

Reply via email to