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

            Bug ID: 87707
           Summary: actual argument to assumed type dummy argument (i.e.
                    type(*)) cannot have type-bound procedures
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.diehl at mpie dot de
  Target Milestone: ---

gfortran (confirmed for 6.3.0 and 8.2.1) rejects passing in a derived type to a
subroutine with a type(*) dummy argument with the following message:

Error: Actual argument at (1) to assumed-type dummy is of derived type with
type-bound or FINAL procedures

The documentation on
https://www.ibm.com/support/knowledgecenter/SSAT4T_15.1.4/com.ibm.xlf1514.lelinux.doc/language_ref/assumedtypeobj.html
implies that this is the expected behavior (An assumed-type dummy argument
cannot correspond to an actual argument of a derived type that has type
parameters, type-bound procedures, or final subroutines.). However, I cannot
confirm this from https://j3-fortran.org/doc/year/18/18-007r1.pdf. See also the
discussion in the Intel developer zone:
https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/798744
(Intel Fortran accepts the code). Probably this restriction was part of an
earlier draft.
I compile with '-std=f2008ts' or '-std=f2018'.

This is my test code (need to be split into 2 files)
program main
  use context_module
  implicit none
  type(context_type) :: context

  call test(context) 

end program main

module context_module

  implicit none

  type ::  context_type
    integer, private :: foo

    contains
      procedure, public :: init => context_init
   end type context_type

contains

  subroutine context_init(self, foo)
   implicit none
    class(context_type), intent(in out) :: self
    integer, intent(in) :: foo
    self%foo = foo
  end subroutine context_init


 subroutine test(context)
   implicit none
   type(*) :: context
   write(6,*) 'hello world'   
 end subroutine

end module context_module

Reply via email to