Bug ID: 78009
           Summary: [OOP] polymorphic component of derived type array
                    slice handling error
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot
          Reporter: daanvanvugt at gmail dot com
  Target Milestone: ---

When setting a component of a polymorphic type in an array memory offsets of
the base type are used. This only occurs if it is nested in another allocatable

See the attached program for an example. Expected output is
1 0
1 0
... etc
instead a different memory region is set to 1.

program test
  type :: t
    integer :: a
  end type t
  type, extends(t) :: tt
    integer :: b
  end type tt
  type :: group
    class(t), allocatable, dimension(:) :: unit
  end type group

  type(group), allocatable, dimension(:) :: groups
  groups(1)%unit(:)%a = 1

  select type (units => groups(1)%unit)
  type is (tt)
  do i=1,10
    write(*,*) units(i)%a, units(i)%b
  end do
  end select
end program test

Reply via email to