I'm on VC++11, so far those values generate errors, but not on ideone.com
#include "stdafx.h"
#include <iostream>
#include <random>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
//int main(int argc, char* argv[])
{
//print_seq(seeded_rand(0x7fffffff,10));
//cout << print_seq(seeded_rand(0xffffffff,10));
////print_seq(seeded_rand(0,10));
//cout << print_seq(seeded_rand(-50000,10));
//cout << print_seq(seeded_rand(1,10));
minstd_rand r1;
minstd_rand0 r2;
r1.seed(0);
system("PAUSE");
return 0;
}
Those values also generated errors
0xfffffffe
0x7fffffff
-2
0
what other values are supposed to generate an abort() call ?

visual C++ 11.0.61030.0 update 4
26.5.3.1/5
explicit linear_congruential_engine(result_type s = default_seed);Effects: Constructs alinear_congruential_engineobject. Ifc mod mis 0 ands mod mis 0, sets the engine’s state to 1, otherwise sets the engine’s state tos mod m.
For some reason, MSVC implementation chooses to assert in debug build when the "sets the engine’s state to 1" condition triggers; in release build, it just quietly seeds with 1 instead of 0.
minstd_rand is a typedef for linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>. So any seed that is 0 modulo 2147483647 == 0x7FFFFFFF is meaningless (the generator would just produce a sequence of zeros, if it weren't adjusting the seed to 1 in this case).
User contributions licensed under CC BY-SA 3.0