From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4415A3840C14; Tue, 14 May 2024 09:52:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4415A3840C14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715680334; bh=4KmRZH2PMqD8vVj2cGHRIP/LTXQTMI3DSnw96aq+bGA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KezbqjA6ojy3OqMDu3T2E4Iud9rlcSXVPpla2xB5xFAV1LSj2smt7+5Z/muKSdy84 I1rhiu1t4U93LPHH6jyvDvN3mZVjKI5mNHKaxppgADKJYP6AJ5GwjyRMM3WtW9sow9 U+dOZG4zOrndYy3Qz/VggmkJdA66uXayp3oJTcok= 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, 14 May 2024 09:52:13 +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 #6 from GCC Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:71e941b0e329d3a316e465569c92e08788a68614 commit r13-8771-g71e941b0e329d3a316e465569c92e08788a68614 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)=