From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A05C5385842A; Tue, 31 Aug 2021 09:39:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A05C5385842A From: "gcc@christoph-conrads.name" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/89979] subtract_with_carry_engine incorrect carry flag Date: Tue, 31 Aug 2021 09:39:24 +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: 8.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc@christoph-conrads.name X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2021 09:39:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D89979 --- Comment #4 from Christoph Conrads --- > LLVM's libc++ does not go into the 0 loop but still does not do a good jo= b: The subtract-with-carry PRNG is a simple PRNG, it has a very long period wh= ose length can be proved with elementary number theory but the randomness properties of an SWC on its own are bad which is why you have to discard a = lot of values. For reference, std::ranlux48 uses about 11 out of 389 values and= you can detect (self-advertisement: it discards much less variates if you you u= se my parameters: b=3D32, s=3D2, r=3D13, see https://github.com/boostorg/random/issues/57). Here are the random values are drawing 100 times: 114294 141465 4294632814 252684 106646 4294497449 475286 Here are the random values after drawing 1000 times: 3844519667 4029384828 773557245 3005408692 1891078342 2314767096 2602358454 After drawing 2000 times: 671901017 3735908022 2276383719 2942324048 2197640583 3544339665 2823890385=