Not-so-unpredictable seed?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Apr 17 22:05:02 PDT 2012


On 18/04/12 06:43, jerro wrote:
> According to the comment the call to prime() is necessary
> so that the result doesn't always start with the same element.
> But prime() uses the gen member which is only assigned after the
> constructor completes. So at the time when prime() is called the
> gen member is in some default state, so the prime() call in the
> constructor always does the same thing. The fix would be to
> either modify the constructor to take random generator as a
> parameter if Random type parameter is not void, or to move the
> call to prime() out of constructor and into all the randomSample
> functions. In the ones that have a random generator parameter,
> the call to prime should come after gen is asigned.

Ahhh, clear.  I should have worked that out from the code, brain not working 
right today. :-P

It still looks like a serious bug to me, so I've filed a report.
http://d.puremagic.com/issues/show_bug.cgi?id=7936




More information about the Digitalmars-d-learn mailing list