- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear All,
I have some problems with the == operator when using Intel 15. Below the self containing example demonstrating the issue. IMHO, the comparison between instances of the derived types calls the wrong routine (the one of the base type instead of the overriden one of the extending type), when the instances are accessed via class pointers of the base type. Other compilers do it differently, and although I do not have a detailed knowledge of the standard, the behaviour feels incorrect. Any views on that?
Best regards,
Bálint
module testmod implicit none type :: Base contains procedure :: isEqualTo => Base_isEqualTo generic :: operator(==) => isEqualTo end type Base type, extends(Base) :: Extended integer :: ii contains procedure :: isEqualTo => Extended_isEqualTo end type Extended contains function Base_isEqualTo(this, other) result(isEqual) class(Base), intent(in) :: this class(Base), intent(in) :: other logical :: isEqual print *, "Base_isEqualTo invoked" isEqual = .false. end function Base_isEqualTo function Extended_isEqualTo(this, other) result(isEqual) class(Extended), intent(in) :: this class(Base), intent(in) :: other logical :: isEqual print *, "Extended_isEqualTo invoked" select type (other) class is (Extended) isEqual = (this%ii == other%ii) class default isEqual = .false. end select end function Extended_isEqualTo end module testmod program test use testmod implicit none type(Extended), target :: ext1, ext2 class(Base), pointer :: pBase1, pBase2 logical :: isEqual ext1%ii = 1 ext2%ii = 1 pBase1 => ext1 pBase2 => ext2 isEqual = (pBase1 == pBase2) print *, "Equal?", isEqual end program test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code seems to work as expected using Intel Fortran compiler 16.0, initial release. Perhaps you can consider upgrading your compiler?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code seems to work as expected using Intel Fortran compiler 16.0, initial release. Perhaps you can consider upgrading your compiler?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for testing it. Apparently, I'll have to upgrade then. :-)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page