[Bug fortran/84387] New: Defined output does not work for a derived type that has no components
fortranfan at outlook dot com
gcc-bugzilla@gcc.gnu.org
Wed Feb 14 19:16:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84387
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 gnu.org
Reporter: fortranfan at outlook dot com
Target Milestone: ---
Consider the following:
--- begin console output ---
C:\Temp>type p.f90
module m
type :: t
private
!integer :: m_i = 0 !<-- ***
contains
private
procedure, pass(this) :: write_t
generic, public :: write(formatted) => write_t
end type
contains
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!"
return
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
C:\Temp>p.exe
C:\Temp>
--- 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
expected.
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:
C:\Temp>p.exe
Hello World!
Thanks for your time and attention,
Vipul Parekh
More information about the Gcc-bugs
mailing list