This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author corona10
Recipients corona10, mark.dickinson, petdance, vstinner
Date 2020-05-01.17:06:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588352784.8.0.562762104283.issue40455@roundup.psfhosted.org>
In-reply-to
Content
@mark.dickinson @vstinner

I'd like to suggest this change.
There was no performance impact on my local machine.

--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -2852,7 +2852,8 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
 {
     Py_ssize_t a_size, a_bits, shift_digits, shift_bits, x_size;
     /* See below for why x_digits is always large enough. */
-    digit rem, x_digits[2 + (DBL_MANT_DIG + 1) / PyLong_SHIFT];
+    digit rem;
+    digit x_digits[2 + (DBL_MANT_DIG + 1) / PyLong_SHIFT] = {0,};
     double dx;
     /* Correction term for round-half-to-even rounding.  For a digit x,
        "x + half_even_correction[x & 7]" gives x rounded to the nearest
@@ -2903,8 +2904,6 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
         shift_digits = (DBL_MANT_DIG + 2 - a_bits) / PyLong_SHIFT;
         shift_bits = (DBL_MANT_DIG + 2 - a_bits) % PyLong_SHIFT;
         x_size = 0;
-        while (x_size < shift_digits)
-            x_digits[x_size++] = 0;
         rem = v_lshift(x_digits + x_size, a->ob_digit, a_size,
                        (int)shift_bits);
         x_size += a_size;
History
Date User Action Args
2020-05-01 17:06:24corona10setrecipients: + corona10, mark.dickinson, vstinner, petdance
2020-05-01 17:06:24corona10setmessageid: <1588352784.8.0.562762104283.issue40455@roundup.psfhosted.org>
2020-05-01 17:06:24corona10linkissue40455 messages
2020-05-01 17:06:24corona10create