The assignments inside where/elsewhere may affect variables participating
in the mask expression, but execution of the assignments must not affect
the established control mask(s) (F'18 10.2.3.2 p. 13).
The following example must print all 42's:
program test integer c(3) logical :: mask(3) = .true. where (mask) c = f() end where print *, c contains integer function f() mask = .false. f = 42 end function f end program test
I think this applies to FORALL too. See 10.2.4.2.1: the evaluation of the mask-expr happens before execution of the FORALL body.
But it isn't spelt out as clearly as for WHERE/ELSEWHERE