This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/24092] on seeds 0 and 1, srandom() initializes the random number generator in the same way


https://sourceware.org/bugzilla/show_bug.cgi?id=24092

--- Comment #20 from Yann Droneaud <yann at droneaud dot fr> ---
(In reply to Vincent Lefèvre from comment #19)
> (In reply to Yann Droneaud from comment #18)
> > If POSIX doesn't specify the algorithm (see below), having srandom(0) and
> > srandom(1) doing the same is fine. Also, it might exist other seeds that
> > produce the same random number sequences.
> 
> This is not what the user expects. If different seeds can return the same
> random number sequences, this makes srandom() useless.

I agree, it's what any decent PRNG should do, but face it, srandom() / random()
are some kind of relics of an old world, and one should be advised not to use
it.

While a subset of user would expect each value given to srandom() will produce
a distinct set of random() outputs, an other subset of user needs srandom(0) to
generate the same set of random() outputs as srandom(1), because that what's
they got until now.

Modifying the behavior now would break usage for the second subset.

Unfortunately I don't see how it would be possible to conciliate the two use
cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]