https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64952

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Technical, it is a bit similar to:

module m
  integer :: i
contains
  pure subroutine f(x)
    integer, intent(inout) :: x
    x = 2*x + i
  end subroutine
end module m

which doesn't modify "i" but still feels a bit odd as it accesses an
nonexplicitly passed variable. Thus, we may need to also take care of:

   array = elemental(array) * pure_function()

where the pure_function accesses the array, e.g. as "sum(array)". Thus, not
only "elemental" has to be checked for such an access, but also nonelemental
pure functions in the surrounding. On the other hand, it would be probably
faster to do:
  tmp = pure_function()
  array = elemental(array) * tmp
which also avoids this problem. (The FE optimization might do this, but it
should also correctly work with -O0.)

Reply via email to