[issue40455] GCC 10 compiler warnings

Mark Dickinson report at bugs.python.org
Fri May 1 12:08:41 EDT 2020


Mark Dickinson <dickinsm at gmail.com> added the comment:

As to _why_ it's a false positive: at that point in the code, assuming 30-bit limbs and an IEEE 754 binary64 "double", we have (using Python notation for floor division)

    a_size == 1 + (a_bits - 1) // 30

and

    shift_digits == (a_bits - 55) // 30

from which it's clear that

    shift_digits <= (a_bits - 1) // 30 < a_size

so a_size - shift_digits is always strictly positive.

The above doesn't depend on the precise values 55 and 30 - any other positive values would have worked, so even with 15-bit digits and some other double format with fewer bits, we still have "shift_digits < a_size".

And now since the v_rshift call writes "a_size - shift_digits" digits to x, we're guaranteed that at least one digit is written, so `x[0]` is not uninitialised.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40455>
_______________________________________


More information about the Python-bugs-list mailing list