https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63176
Bug ID: 63176 Summary: std::generate_canonical<float, std::numeric_limits<float>::digits> generates 1.0 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: sch...@uni-mainz.de std::generate_canonical can generate 1.0, which does not conform to the c++11 standard. On my box the following program yields "Bug!": #include <iostream> #include <limits> #include <random> int main() { std::mt19937 rng; std::seed_seq sequence{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; rng.seed(sequence); rng.discard(12 * 629143 + 6); float random = std::generate_canonical<float, std::numeric_limits<float>::digits>(rng); if (random == 1.0f) { std::cout << "Bug!\n"; } return 0; } See also http://stackoverflow.com/questions/25668600/is-1-0-a-valid-random-number for a longer discussion and analysis of the problem. I first noticed this on my system GCC, gcc (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. but I can reproduce the same behavior with a recent GCC from git: gcc (GCC) 5.0.0 20140830 (experimental) Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I used `c++ =std=c++11` to compile the program above.