[J3] Inquiry on standard conformance with type-bound procedure with PRIVATE atttibute and generic binding and type extension

Vipul Parekh parekhvs at gmail.com
Wed Jun 26 10:36:52 EDT 2019


Does the following code conform?

module a
   type :: a_t
      integer :: i = 1
   contains
      procedure, private :: sub => sub_a_t
      generic :: proc => sub
   end type
contains
   subroutine sub_a_t( this )
      class(a_t), intent(in) :: this
      print *, "in sub_a_t"
      print *, "this%i = ", this%i
   end subroutine
end module
module e
   use a, only : a_t
   type, extends(a_t) :: e_t
      integer :: j = 2
   contains
      procedure, private :: sub => sub_e_t
   end type
contains
   subroutine sub_e_t( this )
      class(e_t), intent(in) :: this
      print *, "in sub_e_t"
      call this%a_t%proc()
      print *, "this%j = ", this%j
   end subroutine
end module
   use e, only : e_t
   type(e_t) :: foo
   call foo%proc()
end

Two different processors compile the above code without any errors and
warnings, however the output from the program is different:

1) with processor A, the output is
    in sub_a_t
    this%i =  1

2) whereas with processor B, the output is
    in sub_e_t
    in sub_a_t
    this%i =            1
    this%j =            2

Looking at 18-007r1, my impression is the code conforms but the output
with processor B shown above is incorrect.  Meaning the binding-name
'sub' in the extension type does not extend the generic-spec of 'proc'
because the binding-name in the parent type is private and thus is
inaccessible in module e.

However I'm not completely sure about this and I fail to put together
the words from sections 7.5.5 on type-bound procedure, section 7.5.7
on type extension, section 7.5.7.2 on inheritance, section 7.5.7.3 on
procedure overriding, etc. to show processor B is clearly wrong.  Is
this in the processor-dependent category? Or is the code itself
non-conforming to begin with?

I appreciate any guidance on this.

Thanks,
Vipul Parekh


More information about the J3 mailing list