https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114359

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:bd31ecc1c7aef5b4ae7ddb04926a2f4105957df4

commit r12-10538-gbd31ecc1c7aef5b4ae7ddb04926a2f4105957df4
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.

    (cherry picked from commit 07e03761a7fc1626a6a74ed957e117f56981558c)

Reply via email to