[ python-Bugs-1545668 ] gcc trunk (4.2) exposes a signed integer overflows

SourceForge.net noreply at sourceforge.net
Thu Aug 24 05:14:44 CEST 2006


Bugs item #1545668, was opened at 2006-08-24 03:14
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1545668&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Macintosh
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Jack Howarth (jwhowarth)
Assigned to: Jack Jansen (jackjansen)
Summary: gcc trunk (4.2) exposes a signed integer overflows

Initial Comment:
While building python 2.4.3 with the current gcc trunk (soon to be 4.2), 
I uncovered a signed integer overflows bug in Python with the help of 
one of the gcc developers. The bug I observed is documented in this 
gcc mailing list message...

http://gcc.gnu.org/ml/gcc/2006-08/msg00436.html

The gcc developer comments about its origin are in the messages...

http://gcc.gnu.org/ml/gcc/2006-08/msg00434.html
http://gcc.gnu.org/ml/gcc/2006-08/msg00442.html

which in short says...

It *is* a bug in python, here is the proof:
https://codespeak.net/viewvc/vendor/cpython/Python-r243/dist/src/
Objects/intobject.c?revision=25647&view=markup
Function

* i_divmod*(*register* *long* x, *register* *long* y,

the following lines:

/        /* (-sys.maxint-1)/-1 is the only overflow case. *//
	*if* (y == -1 && x < 0 && x == -x)
		*return* DIVMOD_OVERFLOW;

If overflow is barred then x==-x may happen only when x==0.
This conflicts with x<0, which means that the compiler may assume
that
  x<0 && x==-x
always yields false. This may allow the compiler to eliminate the whole 
if
statement. Hence, clearly python is at fault.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1545668&group_id=5470


More information about the Python-bugs-list mailing list