Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

Unlimited polymorphic arguments and Overriding type-bound procedures

John4
Valued Contributor I
496 Views

Hi,

I'm still trying to understand how an unlimited polymorphic argument works (and the Fortran standard is not very helpful), so I'm not really sure if the following code is valid:

[fortran]module mod1
    implicit none
    save

    type, abstract, public :: t_base
        integer :: dummy = 0
    contains
        procedure :: do_something
        procedure :: do_something_else
    end type

contains
    subroutine do_something(this, item)
        class(t_base), intent(IN) :: this
        class(*), pointer, intent(INOUT) :: item
    end subroutine

    subroutine do_something_else(this, item)
        class(t_base), intent(IN) :: this
        class(*), pointer, intent(INOUT) :: item(:)
    end subroutine

end module mod1

module mod2
    use mod1

    implicit none
    save

    type, extends(t_base), public :: t1
        integer :: mydummy
    contains
        procedure :: do_something => do_something_local
    end type

    type, extends(t_base), public :: t2
        integer :: mydummy
    contains
        procedure :: do_something_else => do_something_else_local
    end type

contains
    subroutine do_something_local(this, item)
        class(t1), intent(IN) :: this
        class(*), pointer, intent(INOUT) :: item
    end subroutine

    subroutine do_something_else_local(this, item)
        class(t2), intent(IN) :: this
        class(*), pointer, intent(INOUT) :: item(:)
    end subroutine
end module mod2
[/fortran]
The compiler complains that the procedure signature of do_something_else_local is different from that of do_something_else, and therefore cannot override it; overriding do_something with do_something_local works fine, so it seems to be a rank issue. Am I wrong here?

0 Kudos
1 Solution
Steven_L_Intel1
Employee
496 Views
This problem has been fixed in our sources. I expect the fix to appear in Update 3.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
496 Views
The compiler's behavior here makes no sense to me. I will ask the developers about it. Your code looks fine to me, and certainly overriding do_something_else with do_something_local should fail. Issue ID is DPD200163706.
0 Kudos
Steven_L_Intel1
Employee
497 Views
This problem has been fixed in our sources. I expect the fix to appear in Update 3.
0 Kudos
Reply