Index: include/bits/random.tcc =================================================================== --- include/bits/random.tcc (revision 183637) +++ include/bits/random.tcc (working copy) @@ -1,6 +1,6 @@ // random number generation (out of line) -*- C++ -*- -// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -49,6 +49,8 @@ // // Preconditions: a > 0, m > 0. // + // XXX FIXME: as-is, only works correctly for __m % __a < __m / __a. + // template struct _Mod { @@ -2771,8 +2773,8 @@ ^ __begin[(__k + __p) % __n] ^ __begin[(__k - 1) % __n]); _Type __r1 = __arg ^ (__arg >> 27); - __r1 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, - 1664525u, 0u>(__r1); + __r1 = __detail::__mod<_Type, + __detail::_Shift<_Type, 32>::__value>(1664525u * __r1); _Type __r2 = __r1; if (__k == 0) __r2 += __s; @@ -2793,8 +2795,8 @@ + __begin[(__k + __p) % __n] + __begin[(__k - 1) % __n]); _Type __r3 = __arg ^ (__arg >> 27); - __r3 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value, - 1566083941u, 0u>(__r3); + __r3 = __detail::__mod<_Type, + __detail::_Shift<_Type, 32>::__value>(1566083941u * __r3); _Type __r4 = __r3 - __k % __n; __r4 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value>(__r4); Index: include/bits/random.h =================================================================== --- include/bits/random.h (revision 183637) +++ include/bits/random.h (working copy) @@ -1,6 +1,6 @@ // random number generation -*- C++ -*- -// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -174,6 +174,11 @@ static_assert(__m == 0u || (__a < __m && __c < __m), "template argument substituting __m out of bounds"); + // XXX FIXME: + // _Mod::__calc should handle correctly __m % __a >= __m / __a too. + static_assert(__m % __a < __m / __a, + "sorry, not implemented yet: try a smaller 'a' constant"); + public: /** The type of the generated random value. */ typedef _UIntType result_type;