[J3] Question about interface matchine

Brad Richardson everythingfunctional at protonmail.com
Wed Jan 27 22:24:05 UTC 2021


Hi all,

Could someone please tell me whether the following code is standards conformant, and if so why? I contend that both the declared and dynamic type of bar do not match the interface and thus the code should not compile or execute without error. But gfortran, intel, and nag all compile and execute this code without complaint. Is there something about interface matching and argument types that I’m not understanding?

module foo_m
    implicit none

    type :: foo_t
    contains
        procedure :: copy_into
    end type

    type, extends(foo_t) :: bar_t
    end type
contains
    subroutine copy_into(self, rhs)
        class(foo_t), intent(inout) :: self
        type(foo_t), intent(inout) :: rhs
    end subroutine
end module

program main
    use foo_m, only: foo_t, bar_t

    implicit none

    type(foo_t) :: foo
    class(foo_t), allocatable :: bar

    bar = bar_t()
    call foo%copy_into(bar)
end program

Thanks,
Brad Richardson


More information about the J3 mailing list