diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-10-09 16:10:31 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-09 16:58:32 +0100 |
commit | 3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0 (patch) | |
tree | 97860d67e7b00d0788d69ea08c4212eaad62569e /gcc | |
parent | bb37ad8cc0fc937c7afcdab471e5d65d176041c3 (diff) | |
download | gcc-3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0.zip gcc-3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0.tar.gz gcc-3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0.tar.bz2 |
libstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311]
This ensures that intermediate results are done in uint32_t values,
meeting the requirement for operations to be done modulo 2^32.
If the target doesn't define __UINT32_TYPE__ then substitute uint32_t
with a class type that uses uint_least32_t and masks the value to
UINT32_MAX.
I've also split the first loop that goes from k=0 to k<m into three
loops, for k=0, [1,s] and [s+1,m). This avoids branching for those three
cases in the body of the loop, and also avoids the concerns in PR 94823
regarding the k-1 index when k==0.
libstdc++-v3/ChangeLog:
PR libstdc++/97311
* include/bits/random.tcc (seed_seq::generate): Use uint32_t for
calculations. Also split the first loop into three loops to
avoid branching on k on every iteration, resolving PR 94823.
* testsuite/26_numerics/random/seed_seq/97311.cc: New test.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-erro
line number.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions