[Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier

t3suzuki at ucsd dot edu gcc-bugzilla@gcc.gnu.org
Tue Nov 15 17:50:40 GMT 2022


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

--- Comment #7 from Tomoya Suzuki <t3suzuki at ucsd dot edu> ---
The following code appears to me to work differently with gcc10 and gcc11.

#include <vector>
#include <algorithm>
#include <random>

int kRandSeed = 27491095;

int
main()
{
  const int n = 16384;
  std::vector<int> v(n);
  std::mt19937 rng(kRandSeed);
  //std::minstd_rand rng;

  for (int i=0; i < n; i++)
    v[i] = i;

  std::shuffle(v.begin(), v.end(), rng);

  for (int i=0; i < n; i++)
    printf("%d\n", v[i]);
}


More information about the Gcc-bugs mailing list