------- Comment #8 from dominiq at lps dot ens dot fr 2008-10-18 09:31 ------- (In reply to comment #7) > This prints "2 2" at the moment, which seems quite reasonable to me; or does > the standard enforce it should print "2 1"?
ifort returns "2 2" and g95 "2 1". As far as I understand the scalarization of elemental procedures, I think g95 is right. Considering the following modification of the code: PROGRAM main IMPLICIT NONE INTEGER :: i, a(2), b(2) a = (/ 1, 2 /) b = (/ 2, 1 /) CALL copy (a((/ 2, 1 /)), a) PRINT *, a a = (/ 1, 2 /) do i = 1, 2 CALL copy (a(b(i)), a(i)) end do PRINT *, a a = (/ 1, 2 /) do i = 2, 1, -1 CALL copy (a(b(i)), a(i)) end do PRINT *, a STOP CONTAINS ELEMENTAL SUBROUTINE copy (a, b) IMPLICIT NONE INTEGER, INTENT(IN) :: a INTEGER, INTENT(OUT) :: b b = a END SUBROUTINE copy END PROGRAM main which gives: 2 1 2 2 2 2 1 1 i.e., a result depending on the order of the scalar do loop, my understanding is that a temporary is required. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35681