[Python-Dev] Before 2.5 - More signed integer overflows
"Martin v. Löwis"
martin at v.loewis.de
Mon Sep 18 08:56:26 CEST 2006
Neal Norwitz schrieb:
> I also tested the fix (see patch below) for the abs() issue and it
> seemed to work for 4.1.1 on 64-bit. I'll apply the patch to head and
> 2.5 and a test after 2.5 is out.
Please also add it to 2.4.
> Index: Objects/intobject.c
> ===================================================================
> --- Objects/intobject.c (revision 51886)
> +++ Objects/intobject.c (working copy)
> @@ -763,7 +763,7 @@
> register long a, x;
> a = v->ob_ival;
> x = -a;
> - if (a < 0 && x < 0) {
> + if (a < 0 && (unsigned long)x == 0-(unsigned long)x) {
Hmm. Shouldn't this drop 'x' and use 'a' instead? If a is
-sys.maxint-1, -a is already undefined.
Regards,
Martin
P.S. As for finding these problems, I would have hoped that
-ftrapv could help - unfortunately, gcc breaks with this
option (consumes incredible amounts of memory).
More information about the Python-Dev
mailing list