public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94823] modulo arithmetic bug in random.tcc Date: Fri, 09 Oct 2020 16:05:39 +0000 [thread overview] Message-ID: <bug-94823-4-7YycFrATVA@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94823-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94823 --- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0 commit r11-3759-g3ee44d4c518d61c6bbf75fcf280edc6ce5326ce0 Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Oct 9 16:10:31 2020 +0100 libstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311] This ensures that intermediate results are done in uint32_t values, meeting the requirement for operations to be done modulo 2^32. If the target doesn't define __UINT32_TYPE__ then substitute uint32_t with a class type that uses uint_least32_t and masks the value to UINT32_MAX. I've also split the first loop that goes from k=0 to k<m into three loops, for k=0, [1,s] and [s+1,m). This avoids branching for those three cases in the body of the loop, and also avoids the concerns in PR 94823 regarding the k-1 index when k==0. libstdc++-v3/ChangeLog: PR libstdc++/97311 * include/bits/random.tcc (seed_seq::generate): Use uint32_t for calculations. Also split the first loop into three loops to avoid branching on k on every iteration, resolving PR 94823. * testsuite/26_numerics/random/seed_seq/97311.cc: New test. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-erro line number.
next prev parent reply other threads:[~2020-10-09 16:05 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-28 14:55 [Bug libstdc++/94823] New: " nathan at gcc dot gnu.org 2020-04-28 20:56 ` [Bug libstdc++/94823] " hiraditya at msn dot com 2020-04-28 22:36 ` pinskia at gcc dot gnu.org 2020-04-28 22:40 ` pinskia at gcc dot gnu.org 2020-04-29 0:27 ` hiraditya at msn dot com 2020-04-29 2:09 ` hiraditya at msn dot com 2020-04-29 12:57 ` nathan at gcc dot gnu.org 2020-10-09 14:59 ` redi at gcc dot gnu.org 2020-10-09 16:05 ` cvs-commit at gcc dot gnu.org [this message] 2020-10-09 16:07 ` redi at gcc dot gnu.org 2022-07-21 21:21 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94823-4-7YycFrATVA@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).