
AMDG Robert Ramey wrote:
Steven Watanabe wrote:
explicit linear_congruential_engine(result_type s = default_seed); Effects: Constructs a linear_congruential_engine object. If c mod m is 0 and s mod m is 0, sets the engine’s state to 1, otherwise sets the engine’s state to s mod m.
So I might be passing two different seeds and generate the same sequence of results? This would be the exact opposite of what I would be trying to do and would likely result in a silent error that would be a major bitch to find.
This is only a major problem if you explicitly pass the seed: boost::minstd_rand gen(42); If the seed comes from somewhere else: boost::minstd_rand gen(time(0)); then either the library or the user has to fix it up. Currently, the statement boost::minstd_rand gen(time(0)); will work almost all the time. However, it is wrong because it will fail when time(0) returns 2147483647. Is it worse to fix things up and possibly have multiple seeds yield that same sequence or to let code like this fail randomly once in a while? It seems to me that this bug is likely to be harder to trace because it won't even be reproducible.
This isn't so much a specifice critcism of this particular situation as I don't really understand the library or the standard. It's more of rant against the things that seem to trap me into spending disproportional amounts of time on a regular basis. This idea of "silently fixing things" seems to be quite popular and to me, is the cause of much grief.
In Christ, Steven Watanabe