------- Comment #1 from rguenth at gcc dot gnu dot org 2006-11-11 11:46 ------- Confirmed. Shorter testcase:
#include <stdio.h> int main() { double rho; double alpha; int iter_count; double oldrho; double work; work = 2.0e+0; for (iter_count=1; iter_count<11; ++iter_count) { fprintf(stderr, "1: %g\n", oldrho); rho = 1 + work * work; fprintf(stderr, "2: %g\n\n", oldrho); alpha = rho / (5.0e-1 * work * work); work = work - alpha * work; oldrho = rho; } return 0; } It should print the same "oldrho" value at "1:" and "2:" each iteration (but the first one, because oldrho is not initialized then, so the behavior is undefined). Appearantly this undefinedness in the first iteration makes the difference here. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu dot | |org Status|UNCONFIRMED |NEW Component|tree-optimization |rtl-optimization Ever Confirmed|0 |1 Keywords| |wrong-code Known to fail| |4.3.0 Known to work| |4.1.2 Last reconfirmed|0000-00-00 00:00:00 |2006-11-11 11:46:11 date| | Summary|-O2 gives wrong results |[4.3 Regression] -O2 gives | |wrong results http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29798