]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix infinite loop in std::binomial_distribution [PR114359]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:22:17 +0000 (13:22 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 19 Mar 2024 15:59:44 +0000 (15:59 +0000)
commit07e03761a7fc1626a6a74ed957e117f56981558c
tree6b66bbf3ca7e2cc3331d1d2c83c20f580f198267
parentc608b57f77a47179899666940c3b8b6a2e5435b2
libstdc++: Fix infinite loop in std::binomial_distribution [PR114359]

The multiplication (4 * _M_t * __1p) can wraparound to zero if _M_t is
unsigned and 4 * _M_t wraps to zero. The third operand has type double,
so do the second multiplication first, so that we aren't multiplying
integers.

libstdc++-v3/ChangeLog:

PR libstdc++/114359
* include/bits/random.tcc (binomial_distribution::param_type):
Ensure arithmetic is done as type double.
* testsuite/26_numerics/random/binomial_distribution/114359.cc: New test.
libstdc++-v3/include/bits/random.tcc
libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc [new file with mode: 0644]
This page took 0.062934 seconds and 6 git commands to generate.