- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This problem has been fixed in our sources. I expect the fix to appear in Update 3.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This problem has been fixed in our sources. I expect the fix to appear in Update 3.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page