[issue1621] Do not assume signed integer overflow behavior
"Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za
"Martin v. Löwis" <report@bugs.python.org> at psf.upfronthosting.co.za
Wed May 13 23:32:42 CEST 2009
Martin v. Löwis <martin at v.loewis.de> added the comment:
> size = Py_SIZE(a) * n;
>
> The multiplication should be safe from overflow, and I don't get
> any warning at all either with this rewrite (using -O3 -Wall -Wextra -
> Wsigned-overflow=5) or from the original code, so there's nothing to
> silence.
This is puzzling, isn't it? It *could* overflow, could it not?
>> I think there is a second solution: perform the multiplication
>> unsigned in the first place.
>
> That would work too. I find the above code clearer, though.
I agree in this case. In general, I'm not convinced that it
is always possible to rewrite the code in that way conveniently.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1621>
_______________________________________
More information about the Python-bugs-list
mailing list