Skip to contentSkip to conversation

-O2 in gcc 2.96 buggy?

DISCUSSION Torsten Weber 3 participants 3 messages Jan 17, 2002 MIPS

lore
Share & tools
lore
#0 lore raw

On a RedHat 7.1 installation I compiled gawk (3.1.0), but gawk crashed (gawk couldn't run glibc-2.2.4/scripts/firstversions.awk, it resulted in:
> (FILENAME=- FNR=1) fatal error: internal error
> Aborted (core dumped)
)
The gawk problem disappeares if I compile without optimizing with -O2 (i.e. optimizing with -O works).

gcc version is 2.96 20000731 (Red Hat Linux 7.1 2.96-99.1)

Is this problem already known, or where is my mistake?

Thanks.

---------------------------------------------------------------
Torsten Weber Heinrich-Hertz-Institut fuer
E-Mail: [email protected] Nachrichtentechnik Berlin GmbH
---------------------------------------------------------------

#1 lore raw
Quoted 9 lines · Torsten Weber

On a RedHat 7.1 installation I compiled gawk (3.1.0), but gawk crashed (gawk couldn't run glibc-2.2.4/scripts/firstversions.awk, it resulted in:
> (FILENAME=- FNR=1) fatal error: internal error
> Aborted (core dumped)
)
The gawk problem disappeares if I compile without optimizing with -O2 (i.e. optimizing with -O works).

Quoted 4 lines

gcc version is 2.96 20000731 (Red Hat Linux 7.1 2.96-99.1)

Is this problem already known, or where is my mistake?

Often compiling with -O2 reveals actual bugs in the code of the program, not the compiler. For example, uninitialized variables can come out differently depending on optimization level:

#include <stdlib.h>
#include <stdio.h>

int main()

{
        int foo;
        printf("Foo is %i\n", foo);
        return 0;
}

[justinca@gs256 ~]$ gcc -O0 foo.c -o foo
[justinca@gs256 ~]$ ./foo
Foo is -1073743180
[justinca@gs256 ~]$ gcc -O2 foo.c -o foo
[justinca@gs256 ~]$ ./foo
Foo is 1075157696

-Justin

#2 lore raw
In reply to Torsten Weber
Quoted 9 lines · Torsten Weber

On a RedHat 7.1 installation I compiled gawk (3.1.0), but gawk crashed (gawk couldn't run glibc-2.2.4/scripts/firstversions.awk, it resulted in:
> (FILENAME=- FNR=1) fatal error: internal error
> Aborted (core dumped)
)
The gawk problem disappeares if I compile without optimizing with -O2 (i.e. optimizing with -O works).

Quoted 3 lines

gcc version is 2.96 20000731 (Red Hat Linux 7.1 2.96-99.1)

Is this problem already known, or where is my mistake?

I know a kernel bug caused this problem.

H.J.