[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Warning: gcc 2.7.0 on Linux miscompiles lisparit.c w/ optimization



In clisp-1995-06-23, gcc 2.7.0 miscompiles the function LF_LF_durch_LF
in lfloat.d when optimized (-O or -O2).  One of the most obvious
symptoms is that clisp cannot print floating point numbers with
magnitude below about 10E-8.  Thus, a simple way to test the problem
is by typing ".000000005" at a clisp prompt; if you get a "floating
point underflow" error, then it was compiled with a buggy gcc.

The workaround is to compile lisparit.c without optimization.

I enclose a copy of the bug report I sent to bug-gcc.

> This is gcc 2.7.0, i486-linux (ELF) (H.J. Lu's binary distribution for
> Linux).
> 
> Put the following in a file "bug.c" and compile it with
>   gcc -O -o bug bug.c
> --------------------------------------------------
> #include <stdio.h>
> 
> void bug (unsigned int x, unsigned int y);
> 
> int main(int argc, char **argv) {
>   bug(0x7ffffff3, 0x80000001);
>   return 0;
> }
> 
> void bug (unsigned int x, unsigned int y) {
>   if (x == 0) {
>     printf("Never get here.\n");
>   }
>   if (y == 0) {
>     printf("Never get here.\n");
>   }
>   x -= y;
>   if (x < (unsigned int)0x80000000) {
>     printf("GCC says 0x%x is less than 0x8000000!\n", x);
>   } else {
>     printf("OK.\n");
>   }
> }
> --------------------------------------------------
> 
> When you run "bug", it will say:
> GCC says 0xfffffff2 is less than 0x8000000!
> 
> However, if it is compiled without -O:
>   gcc -o bug bug.c
> it will say "OK."
> 
> This is a 486 running Linux 1.3.8.
> 
> Carl Witty
> cwitty@ai.mit.edu

Carl Witty
cwitty@ai.mit.edu