[RFC] Turning off trapping-math for C and C++ front-ends by default
Project / Subsystem
gcc / gcc
Date
2026-07-01
Proposer
Andrea Pinski <andrew.pinski@oss.qualcomm.com>
Source type
public_inbox
Consensus
Proposed
Sentiment
7/10
Technical tradeoffs
- • Disabling -ftrapping-math by default may improve performance and stability by avoiding issues with problematic optimizations, but could break code that relies on precise FP exception behavior.
- • Aligning with LLVM's default simplifies comparisons but requires addressing the underlying issues in GCC's implementation of -ftrapping-math.
- • Adding diagnostics for related functions improves user awareness but adds complexity to the compiler.
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- discussion_id
- CALvbMcA6P_q7WNm1KOopzxhzRJHFi9T9_STaCtZrm1ZA-0nNtQ@mail.gmail.com
- source_type
- public_inbox
- title
- [RFC] Turning off trapping-math for C and C++ front-ends by default
- headline
- Turn off trapping-math for C and C++ front-ends
- tldr
- GCC defaults to -ftrapping-math, but this has many issues. Proposal: disable it by default for C/C++ and file bugs for problematic cases.
- proposer
- Andrea Pinski <andrew.pinski@oss.qualcomm.com>
- consensus
- Proposed
- outcome
- proposed
- sentiment_score
- 7
- technical_tradeoffs
-
- • Disabling -ftrapping-math by default may improve performance and stability by avoiding issues with problematic optimizations, but could break code that relies on precise FP exception behavior.
- • Aligning with LLVM's default simplifies comparisons but requires addressing the underlying issues in GCC's implementation of -ftrapping-math.
- • Adding diagnostics for related functions improves user awareness but adds complexity to the compiler.
- series_id
- —
- series_role
- standalone
- series_parts
- []
- tags
-
- • gcc
- • compiler-flags
- • floating-point
- • optimization
- url
- https://inbox.sourceware.org/gcc/CALvbMcA6P_q7WNm1KOopzxhzRJHFi9T9_STaCtZrm1ZA-0nNtQ@mail.gmail.com
- bugzilla_url
- —
- date
- 2026-07-01T00:00:00.000Z
[RFC] Turning off trapping-math for C and C++ front-ends by default
Andrea Pinski proposes to disable -ftrapping-math by default for GCC’s C and C++ front-ends. The current default, -ftrapping-math, has been associated with various issues, including code transformations that incorrectly alter exception flag behavior. Pinski argues that this default has been problematic since at least GCC 3.4. The change aims to align GCC’s behavior with Clang/LLVM, which defaults to -fno-trapping-math, and to enable a fair comparison between the two compilers. The discussion also touches on the need for #pragma FENV_ACCESS support and potential diagnostics for calls to related functions.