0

My question references the code below. In Visual Studio 2019 the code runs as expected and I get the random integer values. However, in Clion with the MinGw 5 compiler, the code returns the same value every time. It would seem it is not being seeded properly.

I'd appreciate it if someone could take a moment to shed some light on the issue for me:

int roll_die()
{
    std::random_device random_device;
    std::mt19937 random_engine(random_device());
    std::uniform_int_distribution<int> distribution(MIN_DIE_VALUE, MAX_DIE_VALUE);
    auto const rollValue = distribution(random_engine);
    return rollValue;
}

Thanks, Marc

Marc Holman
  • 56
  • 2
  • 12
  • What compiler are you using with your CLion IDE? Does it support C++11 or later? If it does, have you told it to enable that support? Remember, CLion is an IDE, it is *not* a compiler. It *uses* an external compiler and we need to know what that compiler is in order to help you. – Jesper Juhl Feb 01 '20 at 15:47
  • 2
    Does this answer your question? [Why do I get the same sequence for every run with std::random\_device with mingw gcc4.8.1?](https://stackoverflow.com/questions/18880654/why-do-i-get-the-same-sequence-for-every-run-with-stdrandom-device-with-mingw) – Peter O. Feb 01 '20 at 18:15
  • Hi, thanks for the reply. I am using c++ 14 and the link you gave me does answer the question - I totally overlooked it. Apparently, the Bug is still present in 5. – Marc Holman Feb 02 '20 at 17:04

0 Answers0