[issue7406] int arithmetic relies on C signed overflow behaviour

2021-10-20 Thread Christian Heimes
Christian Heimes added the comment: Python 2 is no longer supported. Python 3's _PyLong_Add() function doesn't rely on overflow. -- nosy: +christian.heimes resolution: -> out of date stage: needs patch -> resolved status: open -> closed ___

[issue7406] int arithmetic relies on C signed overflow behaviour

2015-06-24 Thread Kevin Shweh
Kevin Shweh added the comment: It looks like the fast paths for INPLACE_ADD and INPLACE_SUBTRACT in Python 2 don't have the cast-to-unsigned fix, so they're still relying on undefined behavior. For example, in INPLACE_ADD: /* INLINE: int + int */ register long

[issue7406] int arithmetic relies on C signed overflow behaviour

2014-10-14 Thread Stefan Krah
Changes by Stefan Krah stefan-use...@bytereef.org: -- nosy: -skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7406 ___ ___ Python-bugs-list

[issue7406] int arithmetic relies on C signed overflow behaviour

2013-03-13 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +serhiy.storchaka, skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7406 ___ ___

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-05 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: Thanks Tim. I see that is back in 3.2 rather than in the shift and mask sections. At least I know what to refer to now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7406

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-05 Thread Gregory P. Smith
Changes by Gregory P. Smith g...@krypto.org: -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7406 ___ ___ Python-bugs-list

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-04 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Zooko: Yes; that's the sort of solution that's needed if we're not allowed to assume two's complement with the extraordinary value (- sys.maxint - 1) not a trap representation. If we are allowed to assume this, then more efficient solutions

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-04 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: I consider the binary bitwise operations, for negative ints, to be either undefined or wrongly implemented. Consider the following (3.1) 3^2 1 -3^2 -1 3^-2 -3 -3^-2 3 2^3 1 -2^3 -3 Something change sign just flips the sign of the result,

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-04 Thread Tim Peters
Tim Peters tim.pet...@gmail.com added the comment: Terry, the language reference also says: For the purpose of shift and mask operations, a binary representation is assumed, and negative numbers are represented in a variant of 2's complement which gives the illusion of an infinite string of

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-03 Thread Zooko O'Whielacronx
Zooko O'Whielacronx zo...@zooko.com added the comment: Here is a way to test for overflow which is correct for any C implementation: static PyObject * int_add(PyIntObject *v, PyIntObject *w) { register long a, b; CONVERT_TO_LONG(v, a); CONVERT_TO_LONG(w, b); if

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-03 Thread Zooko O'Whielacronx
Zooko O'Whielacronx zo...@zooko.com added the comment: Here is a set of macros that I use to test for overflow: http://allmydata.org/trac/libzutil/browser/libzutil/zutilimp.h -- ___ Python tracker rep...@bugs.python.org

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-02 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Fixed int_sub, int_add, int_mul, and the fast paths for BINARY_ADD and BINARY_SUB in ceval.c, in r76629 (trunk) and r76630 (release26-maint). -- ___ Python tracker rep...@bugs.python.org

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-11-30 Thread Eric Smith
Changes by Eric Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7406 ___ ___ Python-bugs-list mailing

[issue7406] int arithmetic relies on C signed overflow behaviour

2009-11-29 Thread Mark Dickinson
New submission from Mark Dickinson dicki...@gmail.com: Much of the code in Objects/intobject.c assumes that an arithmetic operation on signed longs will wrap modulo 2**(bits_in_long) on overflow. However, signed overflow causes undefined behaviour according to the C standards (e.g., C99 6.5,