From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17996 invoked by alias); 24 Sep 2011 16:34:13 -0000 Received: (qmail 17780 invoked by uid 22791); 24 Sep 2011 16:34:11 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Sep 2011 16:33:55 +0000 From: "john.salmon at deshaw dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: john.salmon at deshaw dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg01761.txt.bz2 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$