Re: -O2 in gcc 2.96 buggy?

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

 



On Thu, 2002-01-17 at 07:25, Torsten Weber wrote:
> 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?
> 

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

Attachment: pgp00134.pgp
Description: PGP signature


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux