Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
31 Views

No warning when overwriting procedure with different characteristics

Hi all,

this is a question and a feature request just in case someone at Intel is interested.

The source below compiles without warnings, and fails at run-time. In my understanding, the code violates language rules (please correct me here, if I am wrong). It would therefore be neat if the compiler would issue a compile-time warning in situations like that; it took me quite some time to identify a similar issue.

Description:

The code contains an extended derived type (Child) which overwrites a type-bound procedure binding. However, the overwritten binding's (Child_sub) dummy argument (class(X)) characteristics differ from the overwritten binding (type(X)). The corresponding source lines are marked by an asterisk (*).

Terminal output:

ifort test.f90 -g -trace
./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
a.out              0000000000403AF3  Unknown               Unknown  Unknown
libpthread-2.27.s  00007F2987317890  Unknown               Unknown  Unknown
a.out              0000000000402ADF  m_mp_child_sub_            25  test7.f90
a.out              0000000000402C71  MAIN__                     37  test7.f90
a.out              0000000000402A82  Unknown               Unknown  Unknown
libc-2.27.so       00007F2986D31B97  __libc_start_main     Unknown  Unknown
a.out              000000000040296A  Unknown               Unknown  Unknown

Modification:

Swap type and class attributes in lines marked by (*).

Modification terminal output:

ifort test.f90
./a.out 
     7046112

Source "test.f90":

module m
    type :: X
        integer :: i = 1
    end type

    ! Parent and Child
    type :: Parent
    contains
        procedure, nopass :: sub => Parent_sub
    end type
    type, extends(Parent) :: Child
    contains
        procedure, nopass :: sub => Child_sub
    end type

contains 
    ! Parent subroutine
    subroutine Parent_sub(a)
        class(X) :: a        ! (*)
    end subroutine

    ! Child subroutine
    subroutine Child_sub(a)
        type(X) :: a        ! (*)
        print *, a%i
    end subroutine
end module

program test
    use m
    implicit none

    type(X) :: a
    class(Parent), allocatable :: myChild
    allocate(Child::myChild)

    call myChild%sub(a)
end program

Details:

 

  • Product Version: Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.3.199 Build 20190206
  • Host OS and Version: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic

Kind regards
Ferdinand

0 Kudos
2 Replies
Highlighted
Valued Contributor I
31 Views

That is indeed an intel bug. nagfor and gfortran both complain, that

Argument A of overriding type-bound procedure SUB of type CHILD is not polymorphic

 

0 Kudos
Highlighted
New Contributor II
31 Views

Thanks Juergen! I wish ifort had told me exactly that.

0 Kudos