Bug ID: 84538
           Summary: Array of derived type elements incorrectly accessed in
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot
          Reporter: abensonca at gmail dot com
  Target Milestone: ---

The following code results in incorrect behavior with gfortran 8.0.1 (r257956):

module bugMod
  type :: t
     integer :: i
  end type t
  type, extends(t) :: te
     integer :: j
  end type te
  subroutine check(n)
    implicit none
    class(t), intent(inout), dimension(:) :: n
    write (0,*) "FROM MODULE  ",n%i
  end subroutine check
end module bugMod

program bug
  use bugMod
  class(t), allocatable, dimension(:) :: n
  allocate(te :: n(2))
  write (0,*) "FROM PROGRAM ",n%i
  call check(n)
end program bug

$ gfortran -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/nfs/home/abenson/Galacticus/Tools
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 8.0.1 20180223 (experimental) (GCC) 

$ gfortran bug.F90
$ a.out 
 FROM PROGRAM            8           3
 FROM MODULE             8           0

I would expect the output to be the same from the module subroutine as from the
main program.

Reply via email to