Optimization trouble
Christopher Weth
weth@tat.physik.uni-tuebingen.de
Fri Oct 23 05:01:00 GMT 1998
Hi,
when compiling the litte program below without optimization (-O or -O2),
it prints the right results; when optimization is turned on, the results
become funny...
This happens with egcs-2.91.57 on a Linux 2.0.33 system as well as the
gcc 2.7.2.1, Linux 2.0.33, and egcs-2.90.29 980515 (egcs-1.0.3 release) on
IRIX 5.3 11091811 IP20; I did not try on more systems than those.
Best regards,
Chriss
----------------------------
#include <math.h>
#include <iostream.h>
int main() {
double ttab[3], *t1 = ttab;
double tstep = M_PI/3;
double th=tstep;
*(t1++)= sin(th);
for (int i=1; i<3; i++) {
th+=tstep;
*(t1++) = *(t1-1)+sin(th);
}
for (int j=0; j<3; j++)
cout << ttab[j] << endl;
return 0;
}
------------------------------------------------------------------
Christopher Weth
Institut fuer theoretische Astrophysik, Tuebingen
Tel.: (07071) / 29-78653
EMail: weth@tat.physik.uni-tuebingen.de
------------------------------------------------------------------
More information about the Gcc-bugs
mailing list