[J3] Overriding type-bound procedure used in generic
Reuben D. Budiardja
reubendb at ornl.gov
Mon May 5 16:46:49 UTC 2025
Hi all,
I'd like some help with this.
Consider the code below.
1. What should the output be?
Two compilers I tried give:
Init G
Init F
while two other compilers give:
Init F
Init F
2. Should it matter if the access spec of the type-bound statement
"Init_T" is changed to "public"? My understanding is that it should not
(from 19.5.4 24-007), but in my test if I do that all four compilers
then agree in the output:
Init_G
Init_F
Thanks,
Reuben
-----------------------------------
module F_M
implicit none
private
type, public :: F_T
contains
procedure, private, pass :: &
Init_T
generic, public :: &
Init => Init_T
end type F_T
contains
subroutine Init_T ( FS )
class ( F_T ), intent ( inout ) :: &
FS
print*, 'Init F'
end subroutine Init_T
end module F_M
module G_M
use F_M
implicit none
private
type, public, extends ( F_T ) :: G_T
contains
procedure, private, pass :: &
Init_T
end type G_T
contains
subroutine Init_T ( FS )
class ( G_T ), intent ( inout ) :: &
FS
print*, 'Init G'
end subroutine Init_T
end module G_M
program Test
use G_M
implicit none
type ( G_T ), allocatable :: &
G
allocate ( G )
call G % Init ( )
call G % F_T % Init ( )
end program Test
More information about the J3
mailing list