On Sat, Jan 17, 2026 at 8:02 PM Daniel Barboza <[email protected]> wrote: > > Hi, > > The idea from this work is inspired by Bugzilla 80511, suggested by > Andrew in [1], and also by Richard comments about the current state of > Wstrict-overflow in [2], which I'll post here for reference: > > "Ah, we should remove that note. -Wstrict-overflow proved useless IMO, > it's way too noisy as it diagnoses when the compiler relies on overflow > not happening, not diagnosing when it possibly happens. That's not a > very useful diagnostic to have - it does not point to a possible problem > in the code (we could as well diagnose _all_ signed arithmetic > operations for the same argument that we might eventually rely on > overflow not happening)." > > Richard's feeling about Wstrict-overflow is also echoed throughout > Bugzilla 80511. > > This series is dedicated to purge Wstrict-overflow support from > fold-const.cc. Most notably by removing the fold_overflow_warn() helper, > used by the file to issue strict overflow warnings. > > The individual changes are trivial, but the amount of helpers involved, > some of them called outside of fold-const.cc, makes it for a unpleasant > time reviewing the changes. This is the main motivation for the patches > being split they way they are. They can be squashed in fewer patches, or > split in even more patches, if needed. > > Some changes ended up removing certain Wstrict-overflow-N.c tests, which > I believe is a desired side-effect for deprecating Wstrict-overflow. > > If we decide this work in on the right direction I have a second, smaller > follow up series, that excludes the remaining of Wstrict-overflow logic > from GCC. All Wstrict-overflow-N.c test files are removed, all > associated logic in passes also removed, leaving just the command line > option (that I suppose would go through some form of deprecation process > instead of just plain removal).
I'll note this is stage1 material, so do not expect actual review at this point. But thanks for tackling this, I'll happily approve of it. I can see clang accepts -Wstrict-overflow as well, what does it actually do with it? Thanks, Richard. > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705746.html > [2] https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705482.html > > Daniel Barboza (13): > fold-const.cc: remove strict_overflow flag from make_range helpers > fold-const.cc: remove strict_overflow_p from extract_muldiv > fold-const.cc: remove strict_overflow_p from > tree_unary_nonzero_warnv_p > fold-const.cc: remove strict_overflow_p from > tree_binary_nonzero_warnv_p > fold-const.cc: remove strict_overflow_p from > tree_single_nonzero_warnv_p > fold-const.cc: remove strict_overflow_p from tree_expr_nonzero_warnv_p > fold-const.cc: remove strict_overflow_p from > maybe_canonicalize_comparison > fold-const.cc: remove strict_overflow_p from tree_binary_nonnegative > fold-const.cc: remove strict_overflow_p from tree_unary_nonnegative > fold-const.cc: remove strict_overflow_p flag from > tree_single_nonnegative_p > fold-const.cc: remove strict_overflow_p from tree_expr_nonnegative > helpers > fold-const.cc: overhaul tree_expr_nonnegative_(warn)_p > fold-const.cc: remove fold_overflow_warning() > > gcc/c-family/c-ubsan.cc | 6 +- > gcc/c-family/c-warn.cc | 8 +- > gcc/c/c-typeck.cc | 6 +- > gcc/fold-const.cc | 642 +++++---------------- > gcc/fold-const.h | 26 +- > gcc/gimple-fold.cc | 68 +-- > gcc/gimple-fold.h | 2 +- > gcc/gimple-range-fold.cc | 12 +- > gcc/ipa-prop.cc | 3 +- > gcc/testsuite/gcc.dg/Wstrict-overflow-22.c | 13 - > gcc/testsuite/gcc.dg/Wstrict-overflow-24.c | 10 - > gcc/testsuite/gcc.dg/Wstrict-overflow-3.c | 13 - > gcc/testsuite/gcc.dg/Wstrict-overflow-5.c | 13 - > gcc/testsuite/gcc.dg/Wstrict-overflow-9.c | 10 - > gcc/testsuite/gcc.dg/pr56355-1.c | 8 - > gcc/tree-ssa-loop-manip.cc | 4 +- > gcc/tree-ssa-phiopt.cc | 2 +- > gcc/tree-ssa-reassoc.cc | 3 +- > gcc/value-query.cc | 3 +- > 19 files changed, 202 insertions(+), 650 deletions(-) > delete mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-22.c > delete mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-24.c > delete mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-3.c > delete mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-5.c > delete mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-9.c > delete mode 100644 gcc/testsuite/gcc.dg/pr56355-1.c > > -- > 2.43.0 >
