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

--- Comment #1 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, May 28, 2020 at 09:33:08PM +0000, kargl at gcc dot gnu.org wrote:
> 
> Code posted at 
> 
> https://groups.google.com/forum/#!topic/comp.lang.fortran/mW1gV6tyxXk

Here's the code

   implicit none

   type :: t1
     integer :: i
   end type

   type, extends(t1) :: t2
   end type

   class(t1), allocatable :: array1(:,:)
   class(t2), allocatable :: array2(:,:)

   allocate(array1(3,3))
   allocate(array2(3,3))

   select type(b => foo(1))
      type is (t1)
         b%i = 1 !VDC
      type is (t2)
         call sub_with_in_and_inout_param(b,b) !VDC
   end select

   contains

     function foo(i)
       integer :: U(2)
       integer :: i
       class(t1), POINTER :: foo(:)
       ALLOCATE(FOO(2))
       U = (/ 1,2 /)
       if (i>0) then
         foo => array1(2,U)
       else
         foo => array2(2,U)
       end if
     end function

     subroutine sub_with_in_and_inout_param(y, z)
        type(t2), INTENT(IN) :: y(:)
        class(t2), INTENT(INOUT) :: z(:)
        z%i = 10
     end subroutine

end

Reply via email to