It is my understanding that a GENERIC type-bound procedure set defined in a base type can be extended in an extended type, as the attached code does.
The code below has been extracted from a library, and it is the minimum size I have been able to reduce to whilst preserving the compiler behaviour; it compiles cleanly with GNU fortran but fails with Intel.
Any comments? Thanks a lot
Salvatore
----------- Intel -------------
[@login1: test]$ ifort -v
ifort version 19.1.1.217
[@login1: test]$ ifort -o tr tr.f90
tr.f90: error #5286: Ambiguous generic interface SET: previously declared specific procedure S_P_TYPE::M_SCPRECSETI is not distinguishable from this declaration. [B_S_P_TYPE::SCPRECSETI]
tr.f90(210): error #8486: There is no matching specific subroutine for this type bound generic subroutine call. [SET]
call sprec%set('Bar',1.0,info)
-------------^
tr.f90(211): error #8486: There is no matching specific subroutine for this type bound generic subroutine call. [SET]
call sprec%set(s_ag,info)
-------------^
compilation aborted for tr.f90 (code 1)
--------- GNU -----------
[@lagrange BugIntel]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=
http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC)
[@lagrange BugIntel]$ gfortran -o tr tr.f90
-----------------------------------------------------------------
-----Source code tr.f90 -------------
module b_s_p_type
type bsp_type
contains
procedure, pass(prec) :: cseti => scprecseti
procedure, pass(prec) :: csetr => scprecsetr
generic, public :: set => cseti, csetr
end type bsp_type
interface
subroutine scprecseti(prec,what,val,info)
import :: bsp_type
class(bsp_type), intent(inout) :: prec
character(len=*), intent(in) :: what
integer, intent(in) :: val
integer, intent(out) :: info
end subroutine scprecseti
subroutine scprecsetr(prec,what,val,info)
import :: bsp_type
class(bsp_type), intent(inout) :: prec
character(len=*), intent(in) :: what
real, intent(in) :: val
integer, intent(out) :: info
end subroutine scprecsetr
end interface
end module b_s_p_type
subroutine scprecseti(p,what,val,info)
use b_s_p_type, protect_name => scprecseti
implicit none
! Arguments
class(bsp_type), intent(inout) :: p
character(len=*), intent(in) :: what
integer, intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine scprecseti
subroutine scprecsetr(p,what,val,info)
use b_s_p_type, protect_name => scprecsetr
implicit none
class(bsp_type), intent(inout) :: p
character(len=*), intent(in) :: what
real, intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine scprecsetr
module base_p_type
type ml_parms
end type ml_parms
type, extends(ml_parms) :: sml_parms
end type sml_parms
type saggr_data
end type saggr_data
end module base_p_type
module sba_mod
use base_p_type, only : sml_parms, saggr_data
type sba_type
end type sba_type
end module sba_mod
module sbs_mod
use base_p_type
type sbs_type
end type sbs_type
end module sbs_mod
module s_p_type
use base_p_type
use sbs_mod
use sba_mod
use b_s_p_type
type, extends(bsp_type) :: sp_type
contains
procedure, pass(prec) :: setsv => sprecsetsv
procedure, pass(prec) :: setag => sprecsetag
procedure, pass(prec) :: cseti => m_scprecseti
procedure, pass(prec) :: csetr => m_scprecsetr
generic, public :: set => setsv, setag
end type sp_type
interface
subroutine sprecsetsv(prec,val,info)
import :: sp_type, sbs_type
class(sp_type), intent(inout) :: prec
class(sbs_type), intent(in) :: val
integer, intent(out) :: info
end subroutine sprecsetsv
subroutine sprecsetag(prec,val,info)
import :: sp_type, sba_type
class(sp_type), intent(inout) :: prec
class(sba_type), intent(in) :: val
integer, intent(out) :: info
end subroutine sprecsetag
subroutine m_scprecseti(prec,what,val,info)
import :: sp_type
class(sp_type), intent(inout) :: prec
character(len=*), intent(in) :: what
integer, intent(in) :: val
integer, intent(out) :: info
end subroutine m_scprecseti
subroutine m_scprecsetr(prec,what,val,info)
import :: sp_type
class(sp_type), intent(inout) :: prec
character(len=*), intent(in) :: what
real, intent(in) :: val
integer, intent(out) :: info
end subroutine m_scprecsetr
end interface
end module s_p_type
subroutine m_scprecseti(p,what,val,info)
use s_p_type, protect_name => m_scprecseti
implicit none
! Arguments
class(sp_type), intent(inout) :: p
character(len=*), intent(in) :: what
integer, intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine m_scprecseti
subroutine m_scprecsetr(p,what,val,info)
use s_p_type, protect_name => m_scprecsetr
implicit none
class(sp_type), intent(inout) :: p
character(len=*), intent(in) :: what
real, intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine m_scprecsetr
subroutine sprecsetag(p,val,info)
use s_p_type, protect_name => sprecsetag
implicit none
class(sp_type), intent(inout) :: p
class(sba_type), intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine sprecsetag
subroutine sprecsetsv(prec,val,info)
use s_p_type, protect_name => sprecsetsv
class(sp_type), intent(inout) :: prec
class(sbs_type), intent(in) :: val
integer, intent(out) :: info
info = 0
end subroutine sprecsetsv
program try
use s_p_type
type(sp_type) :: sprec
type(sba_type) :: s_ag
integer :: info
call sprec%set('Foo',1,info)
call sprec%set('Bar',1.0,info)
call sprec%set(s_ag,info)
end program try