GCC Newspaper
JULY 29, 2026
gcc Proposed Sentiment 6 / 10

Turning off trapping-math for C and C++ front-ends by default

GCC proposal to disable floating-point exception trapping by default for C/C++ to simplify exception handling.

Richard Biener proposes disabling floating-point exception trapping by default in GCC’s C and C++ front-ends. The goal is to simplify exception handling, as trapping can complicate transformations. Joseph Myers questions the grouping of ‘ieee’ and ‘ieee-alternate’ under a single option, suggesting they encompass a wide range of restrictions. Biener seeks an alternative suggestion that isolates trap-based exceptions.

In the Thread 2 participants
  1. Richard Biener <rguenther@suse.de> proposer

    Suggests disabling floating-point trapping by default for C/C++ to simplify exception handling and asks for alternative suggestions if the proposed option is not suitable.

  2. Joseph Myers <josmyers@redhat.com> reviewer

    Expresses concern that grouping 'ieee' and 'ieee-alternate' might be too broad, as they imply different levels of transformation restrictions.

Technical Tradeoffs

  • Disabling FPU traps by default simplifies compiler optimizations but may require explicit enabling for code that relies on trap behavior.
  • Standardizing FPU exception control via flags like `-ffp-exceptions` aims for clarity but requires careful definition of each level.

In Details

This RFC proposes to change the default behavior of floating-point exception handling in GCC's C and C++ front-ends. Currently, the compiler might enable trapping mechanisms for floating-point operations, which can complicate optimization passes by introducing complex control flow for exception handling. The proposal aims to disable this trapping by default, aligning with a simpler exception model, and queries the best way to control specific floating-point exception behaviors via compiler flags.

For Context
trapping-math
A floating-point behavior where exceptions (like division by zero, overflow, underflow) trigger a trap or interrupt, halting normal execution to handle the exception.
floating-point exceptions
Events that occur during floating-point arithmetic operations, such as Invalid Operation, Division by Zero, Overflow, Underflow, and Inexact Result.
exception handling
The mechanisms by which a program responds to runtime errors or exceptional conditions, such as floating-point exceptions.
Filed Under: GCCfloating-pointexceptionscompilation