https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114359
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:07e03761a7fc1626a6a74ed957e117f56981558c commit r14-9551-g07e03761a7fc1626a6a74ed957e117f56981558c Author: Jonathan Wakely <jwak...@redhat.com> Date: Mon Mar 18 13:22:17 2024 +0000 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.