GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fold-const.cc

fold-const.cc: Remove fold_overflow_warning()

The compiler no longer uses `fold_overflow_warning()` and `pointer_may_wrap_p` in constant folding.

The compiler removes fold_overflow_warning() calls within fold-const.cc, which avoids generating warnings for strict overflow in constant folding. The associated helper function pointer_may_wrap_p no longer has any call sites and is removed as well. This change also removes some now-unnecessary test cases.

In Details

Constant folding occurs in fold-const.cc during compilation, where expressions involving constants are evaluated at compile time. The fold_overflow_warning function was used to emit warnings related to potential integer overflows during this process. The removal of this function simplifies the constant folding logic. pointer_may_wrap_p was related to pointer arithmetic during constant folding.

For Context

Compilers perform constant folding to evaluate constant expressions at compile time rather than runtime, improving program efficiency. When constant folding involves operations that might overflow (exceed the maximum value for a data type), the compiler can issue warnings. This commit removes the mechanism for issuing such warnings in a specific part of the constant folding process, potentially changing the circumstances under which overflow warnings are generated.

Filed Under: optimizationwarningsconstant foldingoverflow