[libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback
authorHubert Tong <hubert.reinterpretcast@gmail.com>
Thu, 16 Aug 2018 23:56:54 +0000 (23:56 +0000)
committerHubert Tong <hubert.reinterpretcast@gmail.com>
Thu, 16 Aug 2018 23:56:54 +0000 (23:56 +0000)
commit2c0fad59dfd1a54e9a76d18aebc8f4fc7e891252
treec539f0ef9910a566e7ba66a3d5f989592d225387
parent9982bb873993c99e4a6a0ade6349519ff193d559
[libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

Summary:
When a seed sequence would lead to having no non-zero significant bits
in the initial state of a `mersenne_twister_engine`, the fallback is to
flip the most significant bit of the first value that appears in the
textual representation of the initial state.

rand.eng.mers describes this as setting the value to be 2 to the power
of one less than w; the previous value encoded in the implementation,
namely one less than "2 to the power of w", is replaced by the correct
value in this patch.

Reviewers: mclow.lists, EricWF, jasonliu

Reviewed By: mclow.lists

Subscribers: mclow.lists, jasonliu, EricWF, christof, ldionne, cfe-commits

Differential Revision: https://reviews.llvm.org/D50736

llvm-svn: 339969
libcxx/include/random
libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq_all_zero.pass.cpp [new file with mode: 0644]