https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114359
Bug ID: 114359 Summary: std::binomial_distribution hangs in infinite loop Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: angelo.landi at outlook dot com Target Milestone: --- Created attachment 57715 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57715&action=edit minimal example to expose the issue Due to an integer overflow: in any std::binomial_distribution<IntType> initialized with 2^n trials with n >= (bit size of IntType) - 2, operator() will be stuck in the do-while(__reject) loop forever. The issue was originally found on StackOverflow by user Floyd Everest: https://stackoverflow.com/questions/75179395/stdbinomial-distribution-hangs-forever-with-certain-inputs/75179982 You can find a more detailed explanation of the issue in my answer to that post: https://stackoverflow.com/questions/75179395/stdbinomial-distribution-hangs-forever-with-certain-inputs/75179982#75179982