This is a similar problem to PR33686. $ cat test.f90 integer :: p(4) = (/2,4,1,3/) p(p) = (/(i, i = 1, 4)/) print *, p end
$ ./a 3 1 4 3 7.5.1.5 Interpretation of intrinsic assignments Execution of an intrinsic assignment causes, in effect, the evaluation of the expression expressions within variable (7.1.7), the possible conversion of expr to the type and type of variable (Table 7.10), and the definition of variable with the resulting value. The execution assignment shall have the same effect as if the evaluation of all operations in expr occurred before any portion of variable is defined by the assignment. The evaluation within variable shall neither affect nor be affected by the evaluation of expr. No value variable if variable is of type character and zero length, or is an array of size zero. ....snip.... The processor may perform the element-by-element assignment in any order. I take all this to mean that expressions within variable must be evaluated before the assignment, so that the correct result should be $ ./a 3 1 4 2 Paul -- Summary: Wrong evaluation of expressions in lhs of assignment statements Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pault at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33749