(j3.2006) TS 29113: INTENT(out) and TYPE(*)

Tobias Burnus burnus
Mon Mar 5 04:28:25 EST 2012

Dear all,

I am sure that I just fail to correctly read the standard, but I have problems

The following seems to be allowed, but I fail to see how it can work:

  type t
   integer :: a = 5
  end type t
  type(t) :: var
  var%a = 8
  call one(x)
  print *, var%a
  subroutine one(x)
    type(*) :: x
    call two(x)
  end subroutine two
  subroutine two(y) ! optionally with Bind(C).
    type(*), intent(out) :: y 
  end subroutine

Seemingly, the standard allows INTENT(OUT) for unlimited polymorphic types -
and in particular for assumed type variables. But on the other hand, the
default initialization is required (F2008, 5.2.10p3):

"The INTENT (OUT) attribute for a nonpointer dummy argument specifies that
 the dummy argument becomes undefined on invocation of the procedure, except
 for any subcomponents that are default-initialized ( Any actual
 argument that corresponds to such a dummy argument shall be definable.
 The INTENT (OUT) attribute for a pointer dummy argument specifies that on
 invocation of the procedure the pointer association status of the dummy
 argument becomes undefined. Any actual argument that corresponds to such
 a pointer dummy shall be a pointer variable. Any undefinition or definition
 implied by association of an actual argument with an INTENT (OUT) dummy
 argument shall not act any other entity within the statement that invokes
 the procedure."

(Besides default initialization, a similar issue also exists for
 freeing allocatable components.)


PS: I encountered them when thinking about an implementation of TS 29113
in gfortran. There is now a preliminary support of "TYPE(*)" in the
developer version of GCC 4.8.

More information about the J3 mailing list