Boost logo

Boost :

From: Foelsche, Peter (peter.foelsche_at_[hidden])
Date: 2023-07-18 12:18:46


Dear All,

I'm not certain if the behavior I'm seeing is expected or a problem.

I'm getting different series of numbers from the two different boost versions in question.
When running a diff on the output I'm getting numbers inserted in one series or the other and then the two series become identical again.
Below is the source.

I'm using the following series of commands:

g++ -std=c++14 test.cpp -g -DNDEBUG -fwhole-program -I/mnt/share/boost/boost-1.80/include -o 180
g++ -std=c++14 test.cpp -g -DNDEBUG -fwhole-program -o 160
./180 16384 2078781393 1 > 180.txt
./160 16384 2078781393 1 > 160.txt
diff 160.txt 180.txt |more

The first difference is at line 284. The next at 364, 1783, 2685.

Peter

PS.
g++ (GCC) 5.3.0

PPS.
The source

#include <boost/random.hpp>
#include <boost/version.hpp>
//#include <boost/random/variate_generator.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <limits>
#include <iostream>

int main(int, char**argv)
{ std::cout << BOOST_LIB_VERSION << std::endl;
        const auto bOld = std::atoi(argv[3]) != 0;
        boost::mt19937 sGenerator;
        sGenerator.seed(std::atoi(argv[2]));
        //boost::random::uniform_int_distribution<> sDist(0, std::numeric_limits<int>::max());
        boost::normal_distribution<> sDist(0.0, 1.0);
        boost::variate_generator<boost::mt19937, boost::normal_distribution<> > sGen(sGenerator, sDist);
        for (int i = 0, iMax = std::atoi(argv[1]); i < iMax; ++i)
                if (bOld)
                        std::cout << sDist(sGenerator) << std::endl;
                else
                        std::cout << sGen() << std::endl;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk