Hello- PR61369 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61369) points out that std::discrete_distribution can return an event even if it has 0 probability, and proposes a simple fix. It seems that this fix was never applied, because there was an expectation of redoing this code anyway to use a more efficient algorithm (PR57925). Given that this new algorithm has not been implemented so far, would it make sense to apply the simple fix to address this issue? The attached patch does this. One question about the patch, a slight annoyance is that only std::lower_bound() is currently available in random.tcc, as this file includes only bits/stl_algobase.h and not bits/stl_algo.h (via including ). Is there a preference between simply including stl_algo.h, or moving upper_bound to stl_algobase.h, where lower_bound is? I noticed that in C++20 mode, includes stl_algo.h already, so I figured it would be fine to just include it in random.tcc unconditionally. bootstrap + testing were done on x86-64 GNU/Linux, all tests the same before + after plus 2 new passes from the new test. Thanks for taking a look! -Lewis