Index: boost/random/lagged_fibonacci.hpp =================================================================== --- boost/random/lagged_fibonacci.hpp (revision 50996) +++ boost/random/lagged_fibonacci.hpp (working copy) @@ -317,12 +317,14 @@ unsigned long mask = ~((~0u) << (w%32)); // now lowest w bits set RealType two32 = pow(RealType(2), 32); unsigned int j; - for(j = 0; j < long_lag && first != last; ++j, ++first) { + for(j = 0; j < long_lag && first != last; ++j) { x[j] = RealType(0); for(int k = 0; k < w/32 && first != last; ++k, ++first) x[j] += *first / pow(two32,k+1); - if(first != last && mask != 0) + if(first != last && mask != 0) { x[j] += fmod((*first & mask) / _modulus, RealType(1)); + ++first; + } } i = long_lag; if(first == last && j < long_lag) Index: libs/random/random_test.cpp =================================================================== --- libs/random/random_test.cpp (revision 50996) +++ libs/random/random_test.cpp (working copy) @@ -238,17 +238,17 @@ std::vector::const_iterator it_end = v.end(); URNG urng3(it, it_end); BOOST_CHECK(it != v.begin()); - std::cout << "; seeding uses " << (it - v.begin()) << " words" << std::endl; + std::vector::const_iterator::difference_type n_words = (it - v.begin()); + std::cout << "; seeding uses " << n_words << " words" << std::endl; - bool have_exception = false; - try { - // now check that exceptions are thrown + it = v.end(); + BOOST_CHECK_THROW(urng3.seed(it, it_end), std::invalid_argument); + + if(n_words > 1) { it = v.end(); - urng3.seed(it, it_end); - } catch(std::invalid_argument& x) { - have_exception = true; + --it; + BOOST_CHECK_THROW(urng3.seed(it, it_end), std::invalid_argument); } - BOOST_CHECK(have_exception); // check for min/max members ResultType min = (urng3.min)();