]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108562: Fix compiler warnings for libmpdec (#114751)
authorSergey B Kirpichev <skirpichev@gmail.com>
Sun, 3 Mar 2024 07:25:39 +0000 (10:25 +0300)
committerGitHub <noreply@github.com>
Sun, 3 Mar 2024 07:25:39 +0000 (08:25 +0100)
If awailable, enable -fstrict-overflow for libmpdec. Also
shut off false positive warnings (-Warray-bounds).

The later was backported from mpdecimal-4.0.0.

Makefile.pre.in
Misc/sbom.spdx.json
Modules/_decimal/libmpdec/io.c
configure
configure.ac

index ee65ecd918ce2adcff05834015cc8d3baf0c97d7..396a3d4dca30e4da73f5e0a1bbc478af1ce8c73d 100644 (file)
@@ -1213,7 +1213,7 @@ PYTHON_HEADERS= \
 
 ##########################################################################
 # Build static libmpdec.a
-LIBMPDEC_CFLAGS=@LIBMPDEC_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
+LIBMPDEC_CFLAGS=$(PY_STDMODULE_CFLAGS) @LIBMPDEC_CFLAGS@ $(CCSHARED)
 
 # "%.o: %c" is not portable
 Modules/_decimal/libmpdec/basearith.o: $(srcdir)/Modules/_decimal/libmpdec/basearith.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
index 27e6742292ac6d039ab4a9d68ebd9abca0e2cd38..49c1bf54591a35b651ef3baba82f66699608b7fd 100644 (file)
       "checksums": [
         {
           "algorithm": "SHA1",
-          "checksumValue": "12402bcf7f0161adb83f78163f41cc10a5e5de5f"
+          "checksumValue": "9dcb50e3f9c3245972731be5da0b28e7583198d9"
         },
         {
           "algorithm": "SHA256",
-          "checksumValue": "cba044c76b6bc3ae6cfa49df1121cad7552140157b9e61e11cbb6580cc5d74cf"
+          "checksumValue": "7cac49fef5e9d952ec9390bf81c54d83f1b5da32fdf76091c2f0770ed943b7fe"
         }
       ],
       "fileName": "Modules/_decimal/libmpdec/io.c"
index e7bd6aee170056c1648c0a73bd4b921e449bfab4..4e95b8964c8e5d3caa05b228f610acbe71ff635d 100644 (file)
@@ -48,6 +48,7 @@
 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && __GNUC__ >= 7
   #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
   #pragma GCC diagnostic ignored "-Wmisleading-indentation"
+  #pragma GCC diagnostic ignored "-Warray-bounds"
 #endif
 
 
index 4a980fea4536979fce52629ef3969d72abe8ebb0..c0614138ead4b7a5ea89c1ef9501ca79f8dcf563 100755 (executable)
--- a/configure
+++ b/configure
@@ -14516,6 +14516,13 @@ else $as_nop
   LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
   LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"
 
+    if test "x$ac_cv_cc_supports_fstrict_overflow" = xyes
+then :
+
+    as_fn_append LIBMPDEC_CFLAGS " -fstrict-overflow"
+
+fi
+
     if test "x$with_pydebug" = xyes
 then :
 
index 103c24962b7b420efa54173a89934ed7ff200153..e40b8e0d0de9fc98ff0ef476054bc79f03d5df7b 100644 (file)
@@ -3896,6 +3896,11 @@ AS_VAR_IF([with_system_libmpdec], [yes], [
   LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
   LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"
 
+  dnl Enable strict-overflow for libmpdec, if available, see GH-108562
+  AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes], [
+    AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -fstrict-overflow"])
+  ])
+
   dnl Disable forced inlining in debug builds, see GH-94847
   AS_VAR_IF([with_pydebug], [yes], [
     AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DTEST_COVERAGE"])