Landing: 5f923b5728fb
Project / Subsystem
gcc / gcc
Date
2026-04-26
Author
Roger Sayle
Commit
5f923b5728fb2b94fa539d9a88ee9c95f50e739d
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- commit_hash
- 5f923b5728fb2b94fa539d9a88ee9c95f50e739d
- source_type
- github
- headline
- PR tree-optimization/124715: pow(0,-1) sets errno with -fmath-errno
- tldr
- GCC now avoids transforming pow(x,-1) into 1.0/x when x could be zero and `-fmath-errno` is enabled, preventing incorrect errno settings.
- author
- Roger Sayle
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • errno
- • math
- • correctness
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-04-26T00:00:00.000Z
GCC now respects the -fmath-errno flag when optimizing pow(x, -1) to 1.0/x. The transformation is disabled when x might be zero and -fmath-errno is active, because 1.0/0.0 sets errno while pow(0.0, -1.0) does not. This ensures that the compiler generates code that correctly sets errno when required, improving correctness for programs that rely on this behavior.