Mail Archives: pgcc/1999/08/04/02:13:51
This is a multi-part message in MIME format.
--------------29BD17EA0B63A338F5F21CDC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
The enclosed program fails to compile correctly with PGCC 1.1.3 (the
versions that comes with Mandrake 6.0) when optimization is selected.
The resulting assembly language, when optimization is selected (-O1
for example) fails to include a vital "test" instruction after the
left shift (x << 1), which it does using an "lea" instruction, rather
than a traditional left shift operand. Here is the important section:
if ((long)x < 0 && (sign > 0 || (x << 1) != 0))
goto overflow;
and here is a section of the optimized assembly:
0x8048451 <main+81>: test %ebx,%ebx
0x8048453 <main+83>: jge 0x8048464 <main+100>
0x8048455 <main+85>: cmpl $0x0,0xfffffffc(%ebp)
0x8048459 <main+89>: jg 0x8048470 <main+112>
0x804845b <main+91>: lea 0x0(,%ebx,2),%eax
0x8048462 <main+98>: jne 0x8048470 <main+112>
There should probably be a test between main+91 and main+98 (since lea
sets no condition codes). This bug was discovered when trying to
compile
the Python 1.5.2 sources on a Mandrake 6.0 system; the Python regression
tests were able to determine that the optimized compiled version did not
treat -MAXINT-1 properly (as this piece of code is supposed to handle
the
special wraparound case). Here is the relevant debugging info:
% gcc -v --save-temps -O1 pgcc_bug.c
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/specs
gcc version pgcc-2.91.66 19990314 (egcs-1.1.2 release)
/usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/cpp -lang-c -v -undef
-D__GNUC__=2 -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Di386 -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__ -D__linux__ -D__unix
-D__i386 -D__linux -Asystem(posix) -D__OPTIMIZE__ -Asystem(unix)
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
-Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
pgcc_bug.c pgcc_bug.i
GNU CPP version pgcc-2.91.66 19990314 (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/cc1 pgcc_bug.i -quiet
-dumpbase pgcc_bug.c -O1 -version -o pgcc_bug.s
GNU C version pgcc-2.91.66 19990314 (egcs-1.1.2 release)
(i686-pc-linux-gnu) compiled by GNU C version pgcc-2.91.66 19990314
(egcs-1.1.2 release).
pgcc_bug.c: In function `main':
pgcc_bug.c:12: warning: decimal constant is so large that it is unsigned
as -V -Qy -o pgcc_bug.o pgcc_bug.s
GNU assembler version 2.9.1 (i386-mandrake-linux), using BFD version
2.9.1.0.25 /usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/collect2 -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o
/usr/lib/crti.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/crtbegin.o
-L/usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66 pgcc_bug.o -lgcc -lc
-lgcc /usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/crtend.o
/usr/lib/crtn.o
--------------29BD17EA0B63A338F5F21CDC
Content-Type: text/plain; charset=us-ascii;
name="pgcc_bug.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pgcc_bug.c"
#include <stdlib.h>
#include <stdio.h>
main(int argc, char *argv[])
{
unsigned long x;
int i, sign;
/* This is bogosity to fool the optimizer */
sign = -1;
x = 2147483648;
if (!strcmp(argv[0],
"Never ever run this loop, just use it to insure the optimizer "
"cannot rely on the x and sign vars being constant (and thus optimize"
"away the whole test below exhibiting the bug."))
{
i = 1;
while (--i >= 10000) { /* large value to skip this loop */
x = x-1;
sign = ~sign;
}
}
/*
* end of bogosity section, just needed to establish the threat
* of modifying x, so that the compiler won't optimize it away.
*/
/* This next part exhibits the error. It should NOT goto the overflow label,
because the (sign > 0) || (x << 1) != 0 part should resolve to FALSE.
However, it can be shown that pgcc 1.1.3, when the optimization is on (even -O1),
produces an "lea" instruction to do the left shift and then does a "je" without
a "test". This "test" IS produced when optimization is NOT enabled, and the
program behaves as it should. */
if ((long)x < 0 && (sign > 0 || (x << 1) != 0))
goto overflow;
return (long)x * sign;
overflow:
printf("If this prints, there is a bug\n");
}
--------------29BD17EA0B63A338F5F21CDC
Content-Type: application/octet-stream;
name="pgcc_bug.i.bz2"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="pgcc_bug.i.bz2"
QlpoOTFBWSZTWaYEzvMAEUX/gH////D5f///h+WoDr////9gHT94fQAAC53t7dm53dW89511
J6rt6cJa28mt53Obs3c21523q17gWq49Z1XT0k1oe15xrS453QOgcrD3HdbRUG3bLvdu7buE
iQJkJoU8qam/U000MhT1PKHqAeUAAPUAAB6hoAkQJCIkPVNimJhpMAhhGRpgAAAAmmjADg0a
NA0GgMmIDI0MgADTTIAABggAJNJISNKeQTIJtR6jZR6TaQBoaBiAZNGT1ADQMQRJIKKfgqby
T1NT9KNmmqejTU0D1A0aaADQAABpiAIkiBNBpNIZPRTajRlPUBoGgGjUDIwjQYACG8A1UNYI
wSI+6yqJTFiRQkiQBhAwiShFlSjUpFCBQssjLaVqJJRhStaJQCUhIfcsJGRJAEqCwUWQVxJM
ZCRTGAkEIKEsYSKAMRQUEViSQXsiHYIEIIhU5SBRC/CwAK+fYtUUCyK/LKVBGYlWjWKrlwxB
laqjSWUthblwTKCDUSNgyDaTEC87pMVWUl0mCigijggVtFooNtjbFGtuMMykUhRILUhWbMQh
KVIkcGS2wiqgtssCsFq0uFrjIY44Fq1I5NGQPrbFVNBCKlZRYAtY1JSxWSUikSoxFhU0GZiw
pGKgyWyCjaDVoray6aikEA1QsNqTbMYGW4gmVrYq2tpRjFq2oNsa2W2lHMMmZYYkJKyRZEik
FBkMYQHGhEVkFYqCgiqiKIKioKq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