http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56872
Bug #: 56872 Summary: Incorrect SUM evaluation, involving implied-do loop, with -ffrontend-optimize Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: towns...@astro.wisc.edu The attached code gives the incorrect results when compiled with -ffrontend-optimize (either explicitly, or via use of one of the -O flags). Correct behavior: $ gfortran -o sum_bug sum_bug.f90 $ ./sum_bug 1.00000000 1000.00000 1001.00000 Incorrect behavior (i): $ gfortran -O2 -o sum_bug sum_bug.f90 $ ./sum_bug 1.00000000 1000.00000 1.00000005E-03 Incorrect behavior (ii): $ gfortran -ffrontend-optimize -o sum_bug sum_bug.f90 $ ./sum_bug 1.00000000 1000.00000 Infinity gfortran -v gives: Using built-in specs. COLLECT_GCC=/Applications/madsdk/bin/gfortran.exec COLLECT_LTO_WRAPPER=/Applications/madsdk/libexec/gcc/x86_64-apple-darwin11.4.2/4.9.0/lto-wrapper Target: x86_64-apple-darwin11.4.2 Configured with: ./configure CC='gcc -D_FORTIFY_SOURCE=0' --build=x86_64-apple-darwin11.4.2 --prefix=/Applications/madsdk --with-gmp=/Applications/madsdk --with-mpfr=/Applications/madsdk --with-mpc=/Applications/madsdk --enable-languages=c,c++,fortran --disable-multilib Thread model: posix gcc version 4.9.0 20130404 (experimental) (GCC)