[J3] Question on conformance related to dummy argument with TARGET attribute and INTENT(IN) and function result with POINTER attribute

Vipul Parekh parekhvs at gmail.com
Tue Jun 18 11:34:03 EDT 2019


Is the following code conformant?  The aspects which raise some
concerns include the dummy argument in the function with TARGET
attribute and INTENT(IN) as well as the function result that has the
POINTER attribute.  But there may be other issues with conformance as
well that I will appreciate if anyone can point out to me.

module m
   type :: t
      private
      integer :: m_i = 0
   contains
      procedure :: i => get_i
   end type
contains
   function get_i( this ) result(i)
      class(t), target, intent(in) :: this
      integer, pointer :: i
      i => this%m_i
   end function
end module
   use m, only : t
   type(t) :: foo
   foo%i() = 42
   print *, "foo%i() = ", foo%i(), "; expected is 42"
end

Two compilers I tried do process the above code without any errors or
warnings and produce the output:
 foo%i() =           42 ; expected is 42

Thanks much for your time and attention,
Vipul Parekh


More information about the J3 mailing list