http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53800

             Bug #: 53800
           Summary: [OOP] Wrong copy-in/copy-out when passing CLASS array
                    to assumed-shape TYPE
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org


The reason for problem is that we do not have a stride multiplier.

See http://j3-fortran.org/pipermail/j3/2012-June/005438.html and
http://j3-fortran.org/pipermail/j3/2012-June/005445.html

program class_to_type
   implicit none
   type t
     integer :: i
   end type t
   type, extends(t) :: t2
     integer :: j
   end type t2
   class(t), target, allocatable :: A(:,:)
   type(t), pointer :: ptr

   allocate(t2 :: A(5,5))
   a(:,:)%i = 53
   a(3,3)%i = 42
   a(4,4)%i = 74

   call f(a)
   print *,ptr%i
   a(3,3)%i = 999
   print *,ptr%i
contains
   subroutine f(x)
     type(t), target :: x(:,:)
     ptr => x(3,3)
   end subroutine f
end program class_to_type

Reply via email to