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

--- Comment #34 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Reduced test case for assumed_rank_10.f90

program test
 implicit none
 type t
   integer :: aa
 end type t

 integer, pointer     :: iip

 type(t), pointer     :: jjp

 logical :: is_present

 is_present = .true.

 allocate (iip, jjp)

 iip = 7
 jjp = t(88)

 call fpa(iip, jjp) ! Copy back
 if (iip /= 7 .and. jjp%aa /= 88) call abort ()
 call fpi(iip, jjp) ! No copy back
 if (iip /= 7 .and. jjp%aa /= 88) call abort ()

contains

  subroutine fpa (xx1, yy1)
    integer, pointer :: xx1(..)
    type(t), pointer :: yy1(..)
    if (is_present .neqv. associated (xx1)) call abort ()
    if (is_present .neqv. associated (yy1)) call abort ()
  end subroutine fpa

  subroutine fpi (xx1, yy1)
    integer, pointer, intent(in) :: xx1(..)
    type(t), pointer, intent(in) :: yy1(..)
    if (is_present .neqv. associated (xx1)) call abort ()
    if (is_present .neqv. associated (yy1)) call abort ()
  end subroutine fpi

end program test

The abort is triggered in the fpa/fpi subroutines when the test is compiled
with

[Book15] f90/bug% gfc -O2 -funroll-all-loops assumed_rank_10_red.f90 -m32
[Book15] f90/bug% a.out

Program aborted. Backtrace:
#0  0x1c4a1
#1  0x1e00f
#2  0xd4677
#3  0x15d0f
#4  0x15dd3
Abort

Note that only the fpa/fpi subroutines in the original file assumed_rank_10.f90
cause the abort: if their calls are commented the tests succeed.

Reply via email to