This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
optimization problem with 1.0.3
- To: egcs at egcs dot cygnus dot com
- Subject: optimization problem with 1.0.3
- From: Irwin Lee <itlee at leland dot Stanford dot EDU>
- Date: Sat, 05 Dec 1998 08:59:26 -0800
I'm not sure what to make of this problem. This simple program
behaves differently when compiled with or without optimization.
The problem seems to go away when any of the following happens:
1. The needless 'for' loop is taken out
2. The 'for' loop is replaced with a do {} while(0);
3. Both occurrences of 3.0 are replaced with 2.0
I am working on Intel/Linux.
--------------
beefalo% cat egcs_problem_p.c
#include <stdio.h>
int main()
{
int count;
double x = 1.0;
for(count=0;count<1;count++) {
x = x/3.0;
if(x != 1.0/3.0)
printf("That's odd...\n");
}
return 0;
}
beefalo% gcc egcs_problem_p.c
beefalo% a.out
beefalo% gcc -g0 -O egcs_problem_p.c
beefalo% a.out
That's odd...
beefalo% gcc -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)