#6053 closed Bugs (fixed)
uniform_real goes into an infinite loop when lb=ub
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | To Be Determined | Component: | random |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The following code, compiled on my mac (i686-apple-darwin9-g++-4.2.1) goes into an infinite loop. The problem is in boost::uniform_real<double>(90,90)(rng); as the lower and upper bounds are the same
#include<boost/random/uniform_real.hpp>
#include<boost/random/lagged_fibonacci.hpp>
#include<iostream>
int main() {
boost::lagged_fibonacci607 rng(32);
double r = boost::uniform_real<double>(90,91)(rng); std::cout << r << std::endl;
r = boost::uniform_real<double>(90,90)(rng);
return 0;
}
Change History (6)
comment:1 by , 11 years ago
comment:2 by , 10 years ago
I confirm this bug in libboost 1.48.0-3, running on Ubuntu 12.04, amd64. In my case it failed for boost::uniform_real<double>(-1,1)(rng);
comment:3 by , 10 years ago
I can confirm this on the current release branch (which is going to be 1.50 eventually). Mac OS X 10.7.4, Clang 3.1 and gcc 4.2 both.
comment:4 by , 10 years ago
Can we have the BOOST_ASSERT in the constructor changed to assert that _min < _max instead of _min <= _max ? since _min == _max is not a supported set of parameters? (according to #5059)
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 8 years ago
PS! The documentation still says min <= max. Not sure where to report (or fix) that.
It should be noted that this issue did not occur in Boost 1.46.