Skip to content

Commit b88cd58

Browse files
authored
bpo-40455: Remove gcc10 warning about x_digits (#19852)
* bpo-40455: Remove gcc10 warning about x_digits * bpo-40455: nit * bpo-40455: fix logic error
1 parent 5e8ffe1 commit b88cd58

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Objects/longobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,8 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
28522852
{
28532853
Py_ssize_t a_size, a_bits, shift_digits, shift_bits, x_size;
28542854
/* See below for why x_digits is always large enough. */
2855-
digit rem, x_digits[2 + (DBL_MANT_DIG + 1) / PyLong_SHIFT];
2855+
digit rem;
2856+
digit x_digits[2 + (DBL_MANT_DIG + 1) / PyLong_SHIFT] = {0,};
28562857
double dx;
28572858
/* Correction term for round-half-to-even rounding. For a digit x,
28582859
"x + half_even_correction[x & 7]" gives x rounded to the nearest
@@ -2902,9 +2903,7 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
29022903
if (a_bits <= DBL_MANT_DIG + 2) {
29032904
shift_digits = (DBL_MANT_DIG + 2 - a_bits) / PyLong_SHIFT;
29042905
shift_bits = (DBL_MANT_DIG + 2 - a_bits) % PyLong_SHIFT;
2905-
x_size = 0;
2906-
while (x_size < shift_digits)
2907-
x_digits[x_size++] = 0;
2906+
x_size = shift_digits;
29082907
rem = v_lshift(x_digits + x_size, a->ob_digit, a_size,
29092908
(int)shift_bits);
29102909
x_size += a_size;

0 commit comments

Comments
 (0)