]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40941: Fix fold_tuple_on_constants() compiler warnings (GH-22378)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Sep 2020 12:06:55 +0000 (14:06 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 12:06:55 +0000 (14:06 +0200)
Add explicit casts to fix compiler warnings in
fold_tuple_on_constants().

The limit of constants per code is now INT_MAX, rather than UINT_MAX.

Python/compile.c

index 3ebf221cf02b7165f8a1b2cf59171f0564370a46..0f9e5c276c7b7ba7ffc063b332ce5f8ff0fb8b7e 100644 (file)
@@ -6100,13 +6100,11 @@ fold_tuple_on_constants(struct instr *inst,
         PyTuple_SET_ITEM(newconst, i, constant);
     }
     Py_ssize_t index = PyList_GET_SIZE(consts);
-#if SIZEOF_SIZE_T > SIZEOF_INT
-    if ((size_t)index >= UINT_MAX - 1) {
+    if ((size_t)index >= (size_t)INT_MAX - 1) {
         Py_DECREF(newconst);
         PyErr_SetString(PyExc_OverflowError, "too many constants");
         return -1;
     }
-#endif
     if (PyList_Append(consts, newconst)) {
         Py_DECREF(newconst);
         return -1;
@@ -6116,7 +6114,7 @@ fold_tuple_on_constants(struct instr *inst,
         inst[i].i_opcode = NOP;
     }
     inst[n].i_opcode = LOAD_CONST;
-    inst[n].i_oparg = index;
+    inst[n].i_oparg = (int)index;
     return 0;
 }