https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67011
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2018-05-14 Ever confirmed|0 |1 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Matthias Kretz from comment #3) > The problem is that (result_type(1) - __aurng()) must never be zero (because > std::log might raise FE_DIVBYZERO for std::log(0)). If __aurng() is a > distribution guaranteed to exclude result_type(1) then this works fine. > AFAIK std::generate_canoncial<float> sometimes generates a 1 (cf. > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63176). PR 63176 is fixed now. > Also, I'm wondering whether the 1 - rng wouldn't reduce the randomness. > Consider: > std::log(numeric_limits<float>::min()) -> -87.3365478515625 > std::log(1.f - nextafter(1.f, 0.f)) -> -16.635532379150390625 > IIUC, the effect of log(1 - rng) is that the distance between random values > from std::exponential_distribution is considerable larger than for log(rng). Hmm, let's confirm the bug for that, instead of the division-by-zero that should be fixed.