Landing: 7bed7d9276c1
Project / Subsystem
gcc / libstdc++
Date
2026-05-13
Author
Tomasz Kamiński
Commit
7bed7d9276c11bef5a9a214e20c985af713f1532
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- libstdc++
- patch_id
- —
- commit_hash
- 7bed7d9276c11bef5a9a214e20c985af713f1532
- source_type
- github
- headline
- libstdc++: Prevent overflow in piecewise distribution with empty input.
- tldr
- Avoids reserving size_t(-1) elements when constructing piecewise_constant_distribution or piecewise_linear_distribution with an empty initializer list.
- author
- Tomasz Kamiński
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • libstdc++
- • bugfix
- • memory allocation
- • random number generation
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-13T00:00:00.000Z
The piecewise_constant_distribution and piecewise_linear_distribution constructors in libstdc++ would attempt to reserve size_t(-1) elements when given an empty initializer list, leading to a crash. This commit fixes this by exiting early for empty or near-empty inputs, and avoids unnecessary memory allocations for default configurations.