Opened 11 years ago

Closed 10 years ago

Last modified 8 years ago

#6053 closed Bugs (fixed)

uniform_real goes into an infinite loop when lb=ub

Reported by: dario.izzo@… 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 Ivan Neeson <zzymyn@…>, 11 years ago

It should be noted that this issue did not occur in Boost 1.46.

in reply to:  description comment:2 by matous.ringel@…, 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 Marshall Clow, 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 Edward Rudd <urkle@…>, 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 Steven Watanabe, 10 years ago

Resolution: fixed
Status: newclosed

(In [82937]) Fix assertion for uniform_real. Fixes #6053. Fixes #6059.

comment:6 by anonymous, 8 years ago

PS! The documentation still says min <= max. Not sure where to report (or fix) that.

Note: See TracTickets for help on using tickets.