Overoptimization

Roberto Zunino zunino@cli.di.unipi.it
Mon Apr 10 04:38:00 GMT 2000


The following program gives different results depending of the
optimization options.

$ gcc -Wall -O0 tail.c -o tail
$ ./tail
1
$ gcc -Wall -O1 tail.c -o tail
$ ./tail
0

$ gcc --version
egcs-2.91.66

(gcc-2.95.2 yields the same result)

I've attached the output of gcc -v --save-temps etc.

-------  [cut here]  tail.c
int printf(char *,...);

int f(int a,int *y)
{
  int x = a;

  if (a==0)
    return *y;

  return f(a-1,&x);
}

int main(int argc,char **argv)
{
  return printf("%d\n",f(100,(int *) 0));
}
-------  [cut here]

I'm on a i386, RedHat Linux 6.1.


Zun.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tail.txt.gz
Type: application/x-gzip
Size: 600 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000410/09097abf/attachment.bin>


More information about the Gcc-bugs mailing list