https://github.com/python/cpython/commit/002a5948fc9139abec2ecf92df8b543e093c43fb
commit: 002a5948fc9139abec2ecf92df8b543e093c43fb
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-03-03T08:25:39+01:00
summary:

gh-108562: Fix compiler warnings for libmpdec (#114751)

If awailable, enable -fstrict-overflow for libmpdec. Also
shut off false positive warnings (-Warray-bounds).

The later was backported from mpdecimal-4.0.0.

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

diff --git a/Makefile.pre.in b/Makefile.pre.in
index ee65ecd918ce2a..396a3d4dca30e4 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -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)
diff --git a/Misc/sbom.spdx.json b/Misc/sbom.spdx.json
index 27e6742292ac6d..49c1bf54591a35 100644
--- a/Misc/sbom.spdx.json
+++ b/Misc/sbom.spdx.json
@@ -1224,11 +1224,11 @@
       "checksums": [
         {
           "algorithm": "SHA1",
-          "checksumValue": "12402bcf7f0161adb83f78163f41cc10a5e5de5f"
+          "checksumValue": "9dcb50e3f9c3245972731be5da0b28e7583198d9"
         },
         {
           "algorithm": "SHA256",
-          "checksumValue": 
"cba044c76b6bc3ae6cfa49df1121cad7552140157b9e61e11cbb6580cc5d74cf"
+          "checksumValue": 
"7cac49fef5e9d952ec9390bf81c54d83f1b5da32fdf76091c2f0770ed943b7fe"
         }
       ],
       "fileName": "Modules/_decimal/libmpdec/io.c"
diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c
index e7bd6aee170056..4e95b8964c8e5d 100644
--- a/Modules/_decimal/libmpdec/io.c
+++ b/Modules/_decimal/libmpdec/io.c
@@ -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
 
 
diff --git a/configure b/configure
index 4a980fea453697..c0614138ead4b7 100755
--- 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 :
 
diff --git a/configure.ac b/configure.ac
index 103c24962b7b42..e40b8e0d0de9fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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"])

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to