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

            Bug ID: 90506
           Summary: rejects-valid: function with polymorphic return type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juergen.reuter at desy dot de
  Target Milestone: ---

I don't know whether this already has been reported, it was discussed today
(May 16, 2019) on c.l.f. The following valid code is rejected by gfortran:

   13 |   call do_stuff(g_maker)
      |                1
Error: Actual argument for 'f_maker' must be ALLOCATABLE at (1)

This is the code:
program test_poly

  implicit none

  type f_t
     real :: a
  end type f_t

  type, extends (f_t) :: g_t
     real :: b
  end type g_t

  call do_stuff(g_maker)

contains

  subroutine do_stuff (f_maker)

    interface
       function f_maker () result (f)
         import f_t
         class(f_t), allocatable :: f
       end function f_maker
    end interface

    class(f_t), allocatable :: f

    f = f_maker()

  end subroutine do_stuff

  function g_maker () result (g)

    class(f_t), allocatable :: g

    g = g_t(a=1.,b=1.)

  end function g_maker

end program test_poly

Reply via email to