------- Comment #5 from burnus at gcc dot gnu dot org 2009-07-02 12:36 ------- > > call output (p1, p2, p3, p4) > > That still clobbers p1, p2, p3, and p4 as they are passed by reference so > > is it really undefined code if output changes the values for the do loop? > Yes.
Conformance can now be tested at runtime via -fcheck=do. If one wants to change the loop variable, one should use "i=0; do; i = i + 1; if(i >= 10) exit; end do" instead. >From the F2003 standard, which also applies to loops of the form (2*i, i=1,N) "8.1.6.4.2 The execution cycle": "Except for the incrementation of the DO variable that occurs in step (3), the DO variable shall neither be redefined nor become undefined while the DO construct is active." -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31593