https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98307
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org Known to fail| |10.2.1, 11.0, 8.4.1, 9.3.1 Status|UNCONFIRMED |NEW Keywords| |wrong-code Ever confirmed|0 |1 Last reconfirmed| |2020-12-16 --- Comment #1 from anlauf at gcc dot gnu.org --- Confirmed. Enforcing the creation of a temporary in the forall fixes the issue. Something is missing in the logic of check_forall_dependencies(). Reduced testcase: program evil_forall implicit none type t logical :: valid = .true. integer :: s = 0 !integer, dimension(:), pointer :: p integer, dimension(:), allocatable :: p end type type(t) :: v(2) integer :: i allocate (v(1)%p(8)) allocate (v(2)%p(8)) v(1)%s = 8 v(2)%s = 6 v(1)%p(:) = (/1, 2, 3, 4, 5, 6, 7, 8/) v(2)%p(:) = (/13, 14, 15, 16, 17, 18, 19, 20/) !forall (i=1:2, v(i)%valid) forall (i=1:2) v(i)%p(1:v(i)%s) = v(3-i)%p(1:v(i)%s) end forall if (any(v(2)%p(:) .ne. (/1, 2, 3, 4, 5, 6, 19, 20/))) stop 1 end program