comphelper/source/misc/random.cxx | 3 +++ sc/source/core/opencl/opencl_device.cxx | 2 ++ 2 files changed, 5 insertions(+)
New commits: commit 1b226b02471f2fab5e5e6f79b6593636274d2320 Author: Tor Lillqvist <[email protected]> Date: Tue Oct 7 10:13:05 2014 +0300 Don't call comphelper::rng::uniform_real_distribution(a,b) with a==b Change-Id: I95a3ac8da83e02001de13af8d31a04fe0d654dc0 diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx index 6b99758..917fd24 100644 --- a/sc/source/core/opencl/opencl_device.cxx +++ b/sc/source/core/opencl/opencl_device.cxx @@ -171,6 +171,8 @@ double timerCurrent(timer* mytimer) /* Random number generator */ double random(double min, double max) { + if (min == max) + return min; return comphelper::rng::uniform_real_distribution(min, max); } commit 4bb67e666b2ca36a5caa5c3f22d0f1e802db527e Author: Tor Lillqvist <[email protected]> Date: Tue Oct 7 10:09:44 2014 +0300 Handle incorrect usage of uniform_real_distribution() uniform_real_distribution(a,b) should be called with a < b, otherwise the result is undefined. Currently, when called with both zero, it gets stuck in a loop. Not sure if a blunt assert() would be the right thing here, so I just return a if a >= b. Change-Id: I769688c7192bd02bad24ad597948984db56dd4fc diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx index c695ed1..9071765 100644 --- a/comphelper/source/misc/random.cxx +++ b/comphelper/source/misc/random.cxx @@ -80,6 +80,9 @@ size_t uniform_int_distribution(size_t a, size_t b) // uniform size_t [a,b) distribution double uniform_real_distribution(double a, double b) { + // Probably too rude to just assert(a < b), so instead... + if (a >= b) + return a; boost::random::uniform_real_distribution<double> dist(a, b); return dist(theRandomNumberGenerator::get().global_rng); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
