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.
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 (*).
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
Swap type and class attributes in lines marked by (*).
Modification terminal output:
ifort test.f90 ./a.out 7046112
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