[issue12701] Apple's clang 2.1 (xcode 4.1, OSX 10.7) optimizer miscompiles intobject.c

2011-08-05 Thread deadshort

New submission from deadshort :

Apple Radar ticket 9908625 has been filed. The clang 2.1 optimizer causes 
overflows in Object/intobject.c:int_pow() to be missed, so 2**63 turns into a 
negative integer. The attached test program narrows it down. llvm-gcc is fine, 
so this ticket is mostly an FYI.

idiotbox:Python-2.7.2 cloomis$ ./seqpoint-OK 40 40
a=40, b=40, c(a*b)=-2446744073709551616, c/b=-611686018
overflow detected: 1

  to turn into:

idiotbox:Python-2.7.2 cloomis$ ./seqpoint 4294967296 42
a=4294967296, b=42, c(a*b)=-407881430509551616, c/b=4294967296
overflow detected: 0

--
components: Interpreter Core
files: seqpoint.c
messages: 141701
nosy: deadshort
priority: normal
severity: normal
status: open
title: Apple's clang 2.1 (xcode 4.1, OSX 10.7) optimizer miscompiles intobject.c
versions: Python 2.7
Added file: http://bugs.python.org/file22845/seqpoint.c

___
Python tracker 
<http://bugs.python.org/issue12701>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12701] Apple's clang 2.1 (xcode 4.1, OSX 10.7) optimizer miscompiles intobject.c

2011-08-05 Thread deadshort

deadshort  added the comment:

Blecch: cut-o.
The bad case should have been the matching:

idiotbox:Python-2.7.2 cloomis$ ./seqpoint 40 40
a=40, b=40, c(a*b)=-2446744073709551616, c/b=40
overflow detected: 0

--

___
Python tracker 
<http://bugs.python.org/issue12701>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12701] Apple's clang 2.1 (xcode 4.1, OSX 10.7) optimizer miscompiles intobject.c

2011-08-08 Thread deadshort

deadshort  added the comment:

Yup, that was it. Something new learnt. Thanks.

Not sure how to have configure spot that clang needs the flag. OK, the 
configure stanza for gcc is hardly general; maybe trying $(CC) -fwrapv and  
keeping the flag if that does not blow up on the pad? But I guess that other 
ticket takes care of that.

--

___
Python tracker 
<http://bugs.python.org/issue12701>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1621] Do not assume signed integer overflow behavior

2011-08-10 Thread deadshort

deadshort  added the comment:

Since this is still dribbling along I'll point out intobject.c:int_pow() and:

prev = ix;  /* Save value for overflow check */
if (iw & 1) {
ix = ix*temp;
if (temp == 0)
break; /* Avoid ix / 0 */
if (ix / temp != prev) {
return PyLong_Type.tp_as_number->nb_power(
(PyObject *)v,
(PyObject *)w,
(PyObject *)z);
}
}

which I misclassified in http://bugs.python.org/issue12701

--
nosy: +deadshort

___
Python tracker 
<http://bugs.python.org/issue1621>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com