This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Overoptimization
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Overoptimization
- From: Roberto Zunino <zunino at cli dot di dot unipi dot it>
- Date: Fri, 7 Apr 2000 21:34:42 +0200 (MET DST)
- Organization: Centro di Calcolo - Dipartimento di Informatica di Pisa - Italy
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