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: unassig...@gcc.gnu.org ReportedBy: john.sal...@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: salm...@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; salm...@drdlogin0039.en.desres$