
James E. King, III wrote:
For folks who like (potential) compiler optimization bugs: https://svn.boost.org/trac10/ticket/13247
Looking at the source of independent_bits, this jumps out at me:
S = (S << w0) + (u & y0_mask);
and later
S = (S << (w0 + 1)) + (u & y1_mask);
Shifts with a value more than the number of bits are undefined, and debugging confirms that w0 is 32 in the failing tests.
Possible fix: C:\Projects\boost-git\boost\libs\random>git diff diff --git a/include/boost/random/independent_bits.hpp b/include/boost/random/independent_bits.hpp index dec63b3..835ec32 100644 --- a/include/boost/random/independent_bits.hpp +++ b/include/boost/random/independent_bits.hpp @@ -159,7 +159,14 @@ public: BOOST_ASSERT(n0*w0 + (n - n0)*(w0 + 1) == w); result_type S = 0; - for(std::size_t k = 0; k < n0; ++k) { + if(0 < n0) { + base_unsigned u; + do { + u = detail::subtract<base_result_type>()(_base(), (_base.min)()); + } while(u > base_unsigned(y0 - 1)); + S = (u & y0_mask); + } + for(std::size_t k = 1; k < n0; ++k) { base_unsigned u; do { u = detail::subtract<base_result_type>()(_base(), (_base.min)() ); I also see (unrelated) variant=release errors on msvc-12.0/msvc-14.0, but haven't investigated them. ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_knuth_b.test\msvc-12.0\release\threadapi-win32\threading-multi\test_knuth_b.run... ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_ecuyer1988.test\msvc-12.0\release\threadapi-win32\threading-multi\test_ecuyer1988.run... ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_independent_bits31.test\msvc-12.0\release\threadapi-win32\threading-multi\test_independent_bits31.run... ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_ecuyer1988.test\msvc-14.0\release\threadapi-win32\threading-multi\test_ecuyer1988.run... ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_knuth_b.test\msvc-14.0\release\threadapi-win32\threading-multi\test_knuth_b.run... ...failed testing.capture-output ..\..\bin.v2\libs\random\test\test_independent_bits31.test\msvc-14.0\release\threadapi-win32\threading-multi\test_independent_bits31.run...