This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Overoptimization



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.

tail.txt.gz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]