GetRandomNumber() always return same number in windows platform

Moderator: Project members

Post Reply
Message
Author
twu2
425 Can't open data connection
Posts: 45
Joined: 2005-02-26 16:54

GetRandomNumber() always return same number in windows platform

#1 Post by twu2 » 2015-08-16 03:56

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.

User avatar
botg
Site Admin
Posts: 33041
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse
Contact:

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

#2 Post by botg » 2015-08-16 09:22

I fucking hate compiler vendors shipping nonfunctional stubs in production code.

User avatar
botg
Site Admin
Posts: 33041
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse
Contact:

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

#3 Post by botg » 2015-08-16 20:04

A workaround for this is in the repository.

Post Reply