[TR1] std_run_random failure with VC9 SP1

The std_run_random test is failing on VC9 SP1 (http://tinyurl.com/64xsr5), seemingly because the mersenne_twister implementation doesn't like being seeded with 0: /////////////// void seed(unsigned long _X0 = default_seed) { // set initial values from specified value _RNG_ASSERT(0 < _X0, "invalid argument for mersenne_twister::seed"); /////////////// Is that a bug in SP1, or an incorrect test? Thanks, Richard Webb

Looks like a bug in SP1 - nothing I can see in tr1 requires the parameter to be != 0.

There's the same precondition in IBM XL C/C++ V9.0 for AIX too: [quote from docs at http://tinyurl.com/6xpdtt ] mersenne_twister::seed template<class Gen> void seed(Gen& gen); void seed() {seed(5489); } void seed(unsigned long x0); Precondition: 0 < x0 The first seed function generates N values from the values of type unsigned long returned by successive invocations of gen and then twists the resulting large integer value. Each value is gen() % 2W. The second seed function calls seed(4357). The third seed function sets the oldest historical value h[0] to x0 mod 2W, then iteratively sets each successive historical value h[i] to (i + 1812433253 * (h[i - 1] >> (W - 2))) mod 2W, for i ranging from 1 to N - 1. [/quote] regards Gunther

Gunther Lenz <g.lenz <at> 3gsm.at> writes:
There's the same precondition in IBM XL C/C++ V9.0 for AIX too:
It looks like MS and IBM are both using the Dinkumware lib - the documentation for all 3 is exactly the same. As an observation, i see that the mersenne_twister in boost/tr1/random.hpp says: void seed(unsigned long value) { m_gen.seed(value == 0 ? 5489UL : value); } and the constructor says: explicit mersenne_twister(unsigned long value) : m_gen(value == 0 ? 4357UL : value){} Should those both be 5489?

Richard Webb wrote:
As an observation, i see that the mersenne_twister in boost/tr1/random.hpp says:
void seed(unsigned long value) { m_gen.seed(value == 0 ? 5489UL : value); }
and the constructor says:
explicit mersenne_twister(unsigned long value) : m_gen(value == 0 ? 4357UL : value){}
Should those both be 5489?
Yep, will fix, John.

Richard Webb wrote:
The std_run_random test is failing on VC9 SP1 (http://tinyurl.com/64xsr5), seemingly because the mersenne_twister implementation doesn't like being seeded with 0:
///////////////
void seed(unsigned long _X0 = default_seed) { // set initial values from specified value _RNG_ASSERT(0 < _X0, "invalid argument for mersenne_twister::seed");
///////////////
Is that a bug in SP1, or an incorrect test?
Ah, I believe it may be the test that's incorrect: I've checked the TR text and it's very specific about what seed does, and a zero value makes no real sense. I'll fix the test. Thanks for the catch, John.

Actually fixing that one case causes other similar failures: subtract_with_carry: does not accept a zero argument for the seed, but both the TR1 and the current working draft require this to work (zero arguments gets replaced with the default). subtract_with_carry_01: does not accept a zero argument for the seed, but the TR1 requires this to work (the class is not in the working draft). These really are bugs in the Dinkumware implementation I believe, John.
participants (4)
-
Gunther Lenz
-
John Maddock
-
Joseph Gauterin
-
Richard Webb