I've found a bug in PGCC 1.1.3 when compiling Python 1.5.2 using
optimization, in which the compiler produces incorrect code for a
simple C code sequence.  Those wishing to see this behavior themselves
may download the python 1.5.2 source code and try to compile it using
the normal configure compile sequence, ie:

./configure
make
make test

The test_types regression test will fail, unless the PGCC optimizer is
turned off, ie:

make clean
make OPT=

The bug is exhibited in the file Objects/longobject.c at line 206.
The code is:

        if ((long)x < 0 && (sign > 0 || (x << 1) != 0))
                goto overflow;

And when sign is -1, and (long)x is -2147483648, the program should
NOT execute the goto staement, but it does (only when optimization is
enabled).  Examination of the produced assembly language shows that
PGCC does not include a critical "test" opcode when it should (in this
particular case).

Those wishing for more detail should look for the following thread on
comp.lang.python: "int(long(-sys.maxint-1)) fails on Linux" started 22
July, 1999 (Check Deja.com).  Also, I just submitted a bug report to
the PGCC discussion list.  I also posted a short example program to
the PGCC list which demonstrates the errant behavior, and anyone else
who wants it should e-mail me and ask.

I think this particular bug could certainly affect more things than
simply this one case w/ Python, and the potential effects could be
programs silently giving incorrect results, even when properly
written.  It would certainly be prudent for those Mandrake 6.0 users,
developing w/ the included PGCC, to do regression testing, with both
the optimizer off (as a control) and with it turned on, for important
data results.

Chad Netzer
[EMAIL PROTECTED]

Reply via email to