Boost logo

Boost :

From: Synge Todo (wistaria_at_[hidden])
Date: 2003-04-11 03:21:20


Dear Boosters,

I found that due to a bug in optimizer in SGI MIPSpro C++ compiler
(Version 7.3.1.3m), boost::random::linear_congruential generates
non-positive random numbers, if one specifies optimization flag higher
than -O2.

I have found that this problem can be solved by replacing the
following lines:

    while(value <= 0)
      value += m;

in boost/random/detail/const_mod.hpp by

    for(;;) {
      if (value > 0) break;
      value += m;
    }

Could someone apply this stupid patch???

Synge Todo
wistaria_at_[hidden]

diff -crN boost_1_30_0.orig/boost/random/detail/const_mod.hpp boost_1_30_0/boost/random/detail/const_mod.hpp
*** boost_1_30_0.orig/boost/random/detail/const_mod.hpp Sun May 5 20:57:07 2002
--- boost_1_30_0/boost/random/detail/const_mod.hpp Wed Apr 9 19:43:34 2003
***************
*** 135,142 ****
      assert(r < q); // check that overflow cannot happen
  
      value = a*(value%q) - r*(value/q);
! while(value <= 0)
        value += m;
      return value;
    }
  
--- 135,144 ----
      assert(r < q); // check that overflow cannot happen
  
      value = a*(value%q) - r*(value/q);
! for(;;) {
! if (value > 0) break;
        value += m;
+ }
      return value;
    }
  


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk