int(long(-sys.maxint-1)) fails on Linux
Tim Peters
tim_one at email.msn.com
Fri Jul 23 04:35:07 EDT 1999
[Chad Netzer]
> ...
> Here is some assembly of the same region, compiled with the -O1
> flag, which DOES exhibit the incorrect behavior. Notice that it is
> quite different from the previous code,
Yes, but despite being wrong, it's much faster <wink>.
> ... and I don't know what condition codes "lea" sets,
That's the problem: lea doesn't change any flags (it's the "load effective
address" instruction, and when used for its *intended* purpose (loading
effective addresses <wink>), it would get in the way if it did alter any
flags).
So it's as if "x << 1" had never been computed (which the lea does, btw --
it's tricky!) or tested against 0. They (mis)optimized a necessary "test"
away; see the first version of the working code you posted, which does a
very similar thing in this section (but has the crucial "test" after the
lea).
> clearly the problem is with pgcc w/ optimization turned on, which is a
> Mandrake 6.0 issue.
Yup! You should report it to "them", of course -- such things rarely fix
themselves ...
people-also-introduce-bugs-when-optimizing-so-view-it-as-an-example-
of-advanced-humanistic-ai<wink>-ly y'rs - tim
More information about the Python-list
mailing list