From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2ADA5385DDF8; Tue, 11 Jun 2024 17:06:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2ADA5385DDF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718125591; bh=DoLSydi9TQJ1tZU6dTrbrbA+cYjOgwxknpVFBxQAn08=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hAnJG8ZjEkbBJF8Z+81qJmxgqONeWG+67izoi8HZpaGLKtKFykV+oLMz351kU7tlL zQSBF8MHL9NlL93IXLN8OoeR+j+T8QSKh529yyTXi+Wd9/uJfVmB/wnr3lZMnVy2Ye 35bVqZUf2mpDj2Z6fpUy3mvFDEp03If/btr+d4EI= 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, 11 Jun 2024 17:06:29 +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: 12.4 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 #8 from GCC Commits --- The releases/gcc-12 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:bd31ecc1c7aef5b4ae7ddb04926a2f4105957df4 commit r12-10538-gbd31ecc1c7aef5b4ae7ddb04926a2f4105957df4 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. (cherry picked from commit 07e03761a7fc1626a6a74ed957e117f56981558c)=