This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Optimization trouble
- To: egcs-bugs at cygnus dot com, bug-gcc at prep dot ai dot mit dot edu
- Subject: Optimization trouble
- From: Christopher Weth <weth at tat dot physik dot uni-tuebingen dot de>
- Date: Fri, 23 Oct 1998 13:59:23 +0200 (MEST)
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
------------------------------------------------------------------