Page 1 of 1

GetRandomNumber() always return same number in windows platform

Posted: 2015-08-16 03:56
by twu2
sample code:

Code: Select all

#include <random>
#include <iostream>

int GetRandomNumber(int min, int max)
{
        if (min >= max)
                return min;

        std::uniform_int_distribution<int> dist(min, max);
        std::random_device rd;
        return dist(rd);
}

int main()
{
        for (int i = 0; i < 16; ++i)
          std::cout << GetRandomNumber(0, 10) << "\n";
}
it always return same number under windows.
it look like the same issue like this: http://stackoverflow.com/questions/1888 ... mingw-gcc4

you can turn on the debug information in FileZilla (I test it with 3.13.0), connect to any ftp site, it should send keepalive command every 30 seconds, but it will always send the same command.

Re: GetRandomNumber() always return same number in windows platform

Posted: 2015-08-16 09:22
by botg
I fucking hate compiler vendors shipping nonfunctional stubs in production code.

Re: GetRandomNumber() always return same number in windows platform

Posted: 2015-08-16 20:04
by botg
A workaround for this is in the repository.