Bug ID: 84387
           Summary: Defined output does not work for a derived type that
                    has no components
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot
          Reporter: fortranfan at outlook dot com
  Target Milestone: ---

Consider the following:

--- begin console output ---
C:\Temp>type p.f90
module m

   type :: t
      !integer :: m_i = 0  !<-- ***
      procedure, pass(this) :: write_t
      generic, public :: write(formatted) => write_t
   end type


   subroutine write_t(this, lun, iotype, vlist, istat, imsg)

      ! argument definitions
      class(t), intent(in)            :: this
      integer, intent(in)             :: lun
      character(len=*), intent(in)    :: iotype
      integer, intent(in)             :: vlist(:)
      integer, intent(out)            :: istat
      character(len=*), intent(inout) :: imsg

      write(lun, fmt=*, iostat=istat, iomsg=imsg) "Hello World!"


   end subroutine write_t

end module

program p

   use m, only : t

   type(t) :: foo

   print "(dt)", foo !<-- or list-directed: print *, foo

end program

C:\Temp>gfortran p.f90 -o p.exe


--- end console output ---

Program run-time behavior suggests the defined output with the object foo with
type(t) is not executed. Is this intended?  I didn't notice anything in the
Fortran standard (10-007r1 document toward Fortran 2008) that suggests such a
behavior.  Program built with another compiler printed "Hello World!" as I

Fyi in case it is of any relevance: if the line marked *** above corresponding
to a component of type(t) is uncommented and the program is then rebuilt using
gfortran, the output is:

 Hello World!

Thanks for your time and attention,
Vipul Parekh

Reply via email to