public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "john.salmon at deshaw dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/50509] New: incorrect code in std::seed_seq::generate Date: Sat, 24 Sep 2011 18:14:00 -0000 [thread overview] Message-ID: <bug-50509-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50509 Bug #: 50509 Summary: incorrect code in std::seed_seq::generate Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: john.salmon@deshaw.com The implementation of std::seed_seq::generate contains two typos. The code uses '<<' where the standard in rand.util.seed_seq 26.5.7.1 paragraph 8 says: T(x) is defined as x xor (x rshift 27) Here's a patch against the 4.6.1 tree: salmonj@drdlogin0039.en.desres$ diff -u /proj/desres/root/Linux/x86_64/gcc/4.6.1-23A/include/c++/4.6.1/bits/random.tcc myrandom/bits/random.tcc --- /proj/desres/root/Linux/x86_64/gcc/4.6.1-23A/include/c++/4.6.1/bits/random.tcc 2011-06-27 15:29:53.000000000 -0400 +++ myrandom/bits/random.tcc 2011-09-19 10:04:46.836512000 -0400 @@ -2768,7 +2768,7 @@ _Type __arg = (__begin[__k % __n] ^ __begin[(__k + __p) % __n] ^ __begin[(__k - 1) % __n]); - _Type __r1 = __arg ^ (__arg << 27); + _Type __r1 = __arg ^ (__arg >> 27); __r1 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, 1664525u, 0u>(__r1); _Type __r2 = __r1; @@ -2790,7 +2790,7 @@ _Type __arg = (__begin[__k % __n] + __begin[(__k + __p) % __n] + __begin[(__k - 1) % __n]); - _Type __r3 = __arg ^ (__arg << 27); + _Type __r3 = __arg ^ (__arg >> 27); __r3 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, 1566083941u, 0u>(__r3); _Type __r4 = __r3 - __k % __n; salmonj@drdlogin0039.en.desres$
next reply other threads:[~2011-09-24 16:34 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-09-24 18:14 john.salmon at deshaw dot com [this message] 2011-09-24 18:29 ` [Bug libstdc++/50509] [C++0x] " paolo.carlini at oracle dot com 2011-09-24 18:30 ` paolo at gcc dot gnu.org 2011-09-24 19:06 ` paolo.carlini at oracle dot com 2011-09-24 20:31 ` paolo 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-50509-4@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).