Landing: f139530a10bb
Project / Subsystem
gcc / libstdc++
Date
2026-07-09
Author
Kito Cheng
Commit
f139530a10bbb3c422ec30e1603899428ca5183c
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- libstdc++
- patch_id
- —
- commit_hash
- f139530a10bbb3c422ec30e1603899428ca5183c
- source_type
- github
- headline
- Fix undefined behavior for infinite arguments in ellint phi
- tldr
- Prevents undefined behavior in ellint phi by handling infinite inputs and throwing a domain error.
- author
- Kito Cheng
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • libstdc++
- • math
- • UB
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-09T00:00:00.000Z
This commit addresses undefined behavior in the libstdc++ implementation of __ellint_1, __ellint_2, and __ellint_3 when the ‘phi’ argument is infinity. Previously, the function would compute std::floor(infinity) and cast it to an int, which is undefined behavior since infinity is outside the range of int. This can lead to incorrect code generation, such as infinite loops. The fix replaces this with a check for non-finite ‘phi’ values, throwing a std::domain_error to conform to mathematical function standards and prevent UB.