https://gcc.gnu.org/g:b31a43560e88600d412318f75a43ac8e562ba8c5

commit r17-1058-gb31a43560e88600d412318f75a43ac8e562ba8c5
Author: Daniel Barboza <[email protected]>
Date:   Tue May 26 15:39:30 2026 -0300

    gcc: finalize deprecation of -Wstrict-overflow
    
    The flag has been documented as deprecated since GCC 8:
    
    https://gcc.gnu.org/gcc-8/changes.html
    
    "-fno-strict-overflow is now mapped to -fwrapv -fwrapv-pointer (...)
    -Wstrict-overflow is deprecated."
    
    But we kept it maintained and functional all along these years until GCC
    17, where we're now "finalizing its deprecation" so to speak.
    
    Remove the remaining enum and update all relevant docs and tests to make
    it official.
    
    gcc/c-family/ChangeLog:
    
            * c.opt: Removed Wstrict-overflow entry.
    
    gcc/ChangeLog:
    
            * common.opt: Updated Wstrict-overflow entries to indicate that
            they do nothing now.
            * coretypes.h (enum warn_strict_overflow_code): Enum removed.
            * doc/invoke.texi: Updated Wstrict-overflow entries to indicate
            that they do nothing now.  Also removed the option from the
            "Warning Options" list.
            * opts.cc (common_handle_option): Removed OPT_Wstrict_overflow
            logic.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/opts-1.c: Removed Wnostrict-overflow option test.

Diff:
---
 gcc/c-family/c.opt            |  4 ----
 gcc/common.opt                |  5 ++---
 gcc/coretypes.h               | 24 ----------------------
 gcc/doc/invoke.texi           | 46 +++++++------------------------------------
 gcc/opts.cc                   |  4 +---
 gcc/testsuite/gcc.dg/opts-1.c |  3 +--
 6 files changed, 11 insertions(+), 75 deletions(-)

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index e9c5aabe5712..0c5c47928982 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1443,10 +1443,6 @@ Wstrict-null-sentinel
 C++ ObjC++ Warning Var(warn_strict_null_sentinel)
 Warn about uncasted NULL used as sentinel.
 
-Wstrict-overflow=
-C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 
5)
-;
-
 Wstrict-prototypes
 C ObjC Var(warn_strict_prototypes) Warning
 Warn about unprototyped function declarations.
diff --git a/gcc/common.opt b/gcc/common.opt
index 3ad1444cc884..d816ed6dfb78 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -782,11 +782,10 @@ Warn about code which might break strict aliasing rules.
 
 Wstrict-overflow
 Common Warning
-Warn about optimizations that assume that signed overflow is undefined.
+Does nothing.  Preserved for backward compatibility.
 
 Wstrict-overflow=
-Common Joined RejectNegative UInteger Var(warn_strict_overflow) Warning
-Warn about optimizations that assume that signed overflow is undefined.
+Does nothing.  Preserved for backward compatibility.
 
 Wsuggest-attribute=cold
 Common Var(warn_suggest_attribute_cold) Warning
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 726299f212e9..61f91cd27458 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -320,30 +320,6 @@ enum var_init_status
   VAR_INIT_STATUS_INITIALIZED
 };
 
-/* Names for the different levels of -Wstrict-overflow=N.  The numeric
-   values here correspond to N.  */
-enum warn_strict_overflow_code
-{
-  /* Overflow warning that should be issued with -Wall: a questionable
-     construct that is easy to avoid even when using macros.  Example:
-     folding (x + CONSTANT > x) to 1.  */
-  WARN_STRICT_OVERFLOW_ALL = 1,
-  /* Overflow warning about folding a comparison to a constant because
-     of undefined signed overflow, other than cases covered by
-     WARN_STRICT_OVERFLOW_ALL.  Example: folding (abs (x) >= 0) to 1
-     (this is false when x == INT_MIN).  */
-  WARN_STRICT_OVERFLOW_CONDITIONAL = 2,
-  /* Overflow warning about changes to comparisons other than folding
-     them to a constant.  Example: folding (x + 1 > 1) to (x > 0).  */
-  WARN_STRICT_OVERFLOW_COMPARISON = 3,
-  /* Overflow warnings not covered by the above cases.  Example:
-     folding ((x * 10) / 5) to (x * 2).  */
-  WARN_STRICT_OVERFLOW_MISC = 4,
-  /* Overflow warnings about reducing magnitude of constants in
-     comparison.  Example: folding (x + 2 > y) to (x + 1 >= y).  */
-  WARN_STRICT_OVERFLOW_MAGNITUDE = 5
-};
-
 /* Kind of artificial, compiler-generated lookup table.  Type of the
    second argument of TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA resp.
    targetm.addr_space.for_artificial_rodata.  */
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 09321ca5da95..8edd514e4df3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -445,7 +445,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wsizeof-array-div
 -Wsizeof-pointer-div  -Wsizeof-pointer-memaccess
 -Wstack-protector  -Wstack-usage=@var{byte-size}  -Wstrict-aliasing
--Wstrict-aliasing=@var{n}  -Wstrict-overflow  -Wstrict-overflow=@var{n}
+-Wstrict-aliasing=@var{n}
 -Wstring-compare
 -Wno-stringop-overflow  -Wno-stringop-overread
 -Wno-stringop-truncation  -Wstrict-flex-arrays
@@ -6864,7 +6864,6 @@ Options} and @ref{Objective-C and Objective-C++ Dialect 
Options}.
 -Wsizeof-pointer-div
 -Wsizeof-pointer-memaccess
 -Wstrict-aliasing
--Wstrict-overflow=1
 -Wswitch
 -Wtautological-compare
 -Wtrigraphs
@@ -8718,54 +8717,23 @@ Does not warn about incomplete types.
 @opindex Wno-strict-overflow
 @item -Wstrict-overflow
 @itemx -Wstrict-overflow=@var{n}
-This option is only active when signed overflow is undefined.
-It warns about cases where the compiler optimizes based on the
-assumption that signed overflow does not occur.  Note that it does not
-warn about all cases where the code might overflow: it only warns
-about cases where the compiler implements some optimization.  Thus
-this warning depends on the optimization level.
-
-An optimization that assumes that signed overflow does not occur is
-perfectly safe if the values of the variables involved are such that
-overflow never does, in fact, occur.  Therefore this warning can
-easily give a false positive: a warning about code that is not
-actually a problem.  To help focus on important issues, several
-warning levels are defined.  No warnings are issued for the use of
-undefined signed overflow when estimating how many iterations a loop
-requires, in particular when determining whether a loop will be
-executed at all.
+Does nothing.  Preserved for backward compatibility.
 
 @table @gcctabopt
 @item -Wstrict-overflow=1
-Warn about cases that are both questionable and easy to avoid.  For
-example the compiler simplifies
-@code{x + 1 > x} to @code{1}.  This level of
-@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
-are not, and must be explicitly requested.
+Does nothing.  Preserved for backward compatibility.
 
 @item -Wstrict-overflow=2
-Also warn about other cases where a comparison is simplified to a
-constant.  For example: @code{abs (x) >= 0}.  This can only be
-simplified when signed integer overflow is undefined, because
-@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
-zero.  @option{-Wstrict-overflow} (with no level) is the same as
-@option{-Wstrict-overflow=2}.
+Does nothing.  Preserved for backward compatibility.
 
 @item -Wstrict-overflow=3
-Also warn about other cases where a comparison is simplified.  For
-example: @code{x + 1 > 1} is simplified to @code{x > 0}.
+Does nothing.  Preserved for backward compatibility.
 
 @item -Wstrict-overflow=4
-Also warn about other simplifications not covered by the above cases.
-For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
+Does nothing.  Preserved for backward compatibility.
 
 @item -Wstrict-overflow=5
-Also warn about cases where the compiler reduces the magnitude of a
-constant involved in a comparison.  For example: @code{x + 2 > y} is
-simplified to @code{x + 1 >= y}.  This is reported only at the
-highest warning level because this simplification applies to many
-comparisons, so this warning level gives a very large number of
-false positives.
+Does nothing.  Preserved for backward compatibility.
 @end table
 
 @opindex Wstring-compare
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 09baa411cfd1..17c54b6688e7 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -2952,9 +2952,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_Wstrict_overflow:
-      opts->x_warn_strict_overflow = (value
-                                     ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL
-                                     : 0);
+      /* Deferred.  */
       break;
 
     case OPT_Wsystem_headers:
diff --git a/gcc/testsuite/gcc.dg/opts-1.c b/gcc/testsuite/gcc.dg/opts-1.c
index 3b90fe97dcc6..ef247aa6929d 100644
--- a/gcc/testsuite/gcc.dg/opts-1.c
+++ b/gcc/testsuite/gcc.dg/opts-1.c
@@ -1,9 +1,8 @@
 /* Test negative forms of various options are rejected.  */
 /* { dg-do compile } */
-/* { dg-options "-Wno-strict-aliasing=1 -Wno-strict-overflow=1 
-fno-abi-version=1 -fno-lto-compression-level=1 -fno-tree-parallelize-loops=1" 
} */
+/* { dg-options "-Wno-strict-aliasing=1 -fno-abi-version=1 
-fno-lto-compression-level=1 -fno-tree-parallelize-loops=1" } */
 
 /* { dg-error "-fno-abi-version" "-fno-abi-version" { target *-*-* } 0 } */
 /* { dg-error "-fno-lto-compression-level" "-fno-lto-compression-level" { 
target *-*-* } 0 } */
 /* { dg-error "-fno-tree-parallelize-loops" "-fno-tree-parallelize-loops" { 
target *-*-* } 0 } */
-/* { dg-error "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 
} */
 /* { dg-error "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 
} */

Reply via email to