Landing: 0af021688548

Project / Subsystem

gcc / libstdc++

Date

2026-07-22

Author

Tomasz Kamiński

Commit

0af0216885480c9d25a7c06a461c396d0a24b75c

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
libstdc++
patch_id
—
commit_hash
0af0216885480c9d25a7c06a461c396d0a24b75c
source_type
github
headline
libstdc++: Prevent hangs in uniform_int_distribution
tldr
Fixes infinite loops in uniform_int_distribution when used with non-conforming random number engines.
author
Tomasz Kamiński
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • libstdc++
  • • random
  • • bugfix
discussion_id_link
—
bugzilla_pr
—
date
2026-07-22T00:00:00.000Z

The uniform_int_distribution in libstdc++ could enter an infinite loop when paired with certain random number engines that consistently produce zero. This was due to an algorithm change that rejected low outputs. This patch modifies the rejection path to alternate between the front and back of the output range, ensuring uniformity without causing hangs.