From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 245923858438; Tue, 19 Mar 2024 16:00:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 245923858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710864048; bh=XsmyvNwDoYxAluoFnicZPY0ShaneOgnW8/jZzpUYViU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L1fm/k8A6c4eTnJWglU9auiTgCnT7/w43xJt9gcO2FNjIHnDKu/jb+txL4F+itRZG OClfSTxEUJH0c5Y4O1HM/qJ0YOixqMHc3SKsDWzA3uKqU3nkCyOJOlR1ftZGhkzBud IP9O0oFLAfckB+EAynDOzcksG7hIhEVIJsJC64iI= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114359] std::binomial_distribution hangs in infinite loop Date: Tue, 19 Mar 2024 16:00:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114359 --- Comment #4 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:07e03761a7fc1626a6a74ed957e117f56981558c commit r14-9551-g07e03761a7fc1626a6a74ed957e117f56981558c Author: Jonathan Wakely 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.=