module foo2_mod
use foo_mod
type, extends(foo) :: foo2
integer :: j
contains
procedure, pass(a) :: doit => doit2
procedure, pass(a) :: getit => getit2
!!$ generic, public :: do => doit
!!$ generic, public :: get => getit
end type foo2
private doit2, getit2
contains
subroutine doit2(a)
class(foo2) :: a
a%i = 2
a%j = 3
write(*,*) 'FOO2%DOIT derived version'
end subroutine doit2
function getit2(a) result(res)
class(foo2) :: a
integer :: res
res = a%j
end function getit2
end module foo2_mod
program testd15
use foo2_mod
type(foo2) :: af2
call af2%do()
write(*,*) 'Getit value : ', af2%get()
end program testd15
-------------------------------------------------------------
With a development version of GNU fortran I get the following
output:
[sfilippo@localhost bug15]$ ./testd15
FOO%DOIT base version
Getit value : 1
If I uncomment the two GENERIC statements in module FOO2 I get
[sfilippo@localhost bug15]$ ./testd15
FOO2%DOIT derived version
Getit value : 3
which is what I expected; if I compile with NAG 5.2 I get the second
result in both cases.
So, is the second set of GENERIC statement required by the standard or
not? Or is it unspecified behaviour?
Thanks a lot
Salvatore
Nag compiler gets it right. This seems to be a bug in gFortran. The
GENERIC is Fortran is designed as such that the invocation is resolved
at compile time to a specific binding. In your case, af2%do() and
af2%get() both are solved to call binding a2f%doit() and af2%getit().
These two calls are equvilant to af2%doit() and af2%getit(). And
based on the dynamic type of af2, routines doit2() and getit2() are
both called.
Cheers,
Jim
Many thanks.
Salvatore