https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83153
Bug ID: 83153 Summary: Possible run time error in derived type io example - 2 Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ian at rhymneyconsulting dot co.uk Target Milestone: --- I get a similar error with the following sample code. Here is the derived type module. ##### module ch3702_person_module implicit none type :: person character (len=30) :: name integer :: age real :: height real :: weight contains procedure :: print_person generic :: write(formatted) => print_person procedure :: read_person generic :: read(formatted) => read_person end type person contains subroutine print_person(p,unit_number,iotype,vlist,iostat,iomsg) implicit none class (person) , intent(in) :: p integer , intent(in) :: unit_number character (len=*) , intent(in) :: iotype integer , dimension(:) , intent(in) :: vlist integer , intent(out) :: iostat character (len=*) , intent(inout) :: iomsg character (len=40) :: person_format write(person_format,10)'(a',vlist(1),& ',' ,& 'i',vlist(2),& ',2x,' ,& 'f',vlist(3),& '.',vlist(4),& ',2x,' ,& 'f',vlist(5),& '.0)' 10 format(a,i2,& a, & a,i1,& a, & a,i1,& a,i1,& a, & a,i1,& a) write (unit_number,fmt=person_format) & p%name,p%age,p%height,p%weight iostat=0 end subroutine print_person subroutine read_person(p,unit_number,iotype,vlist,iostat,iomsg) implicit none class (person) , intent(inout) :: p integer , intent(in) :: unit_number character (len=*) , intent(in) :: iotype integer , dimension(:) , intent(in) :: vlist integer , intent(out) :: iostat character (len=*) , intent(inout) :: iomsg character (len=40) :: person_format write(person_format,10)'(a',vlist(1),& ',2x,' ,& 'i',vlist(2),& ',2x,' ,& 'f',vlist(3),& '.',vlist(4),& ',2x,' ,& 'f',vlist(5),& '.0)' 10 format(a,i2,& a, & a,i1,& a, & a,i1,& a,i1,& a, & a,i1,& a) read (unit_number,fmt=person_format) & p%name,p%age,p%height,p%weight iostat=0 end subroutine read_person end module ch3702_person_module ##### Here is the driving program. ##### include 'ch3702_person_module.f90' program ch3702 use ch3702_person_module integer , parameter :: n=4 type (person) , dimension(n) :: p integer :: i open(unit=99,file='ch3701_input_file.txt') do i=1,n read( 99 , 10 ) p(i) 10 format( DT(30,3,4,2,3) ) write( * , 20 ) p(i) 20 format( DT(20,5,4,2,3) ) end do end program ch3702 ##### Here is the input file. I have repeated the inclusion of the file even though it is the same as in the eariler example. ##### Zahpod Beeblebrox 42 1.85 75 Ford Prefect 25 1.75 65 Arthur Dent 30 1.72 68 Trillian 30 1.65 45 ##### Here is the error message. ##### gfortran_ch3702 At line 95 of file ch3702_person_module.f90 (unit = 99, file = 'ch3701_input_file.txt') Fortran runtime error: End of record Error termination. Backtrace: Could not print backtrace: libbacktrace could not find executable to open #0 0xffffffff #1 0xffffffff #2 0xffffffff #3 0xffffffff #4 0xffffffff #5 0xffffffff #6 0xffffffff #7 0xffffffff #8 0xffffffff #9 0xffffffff #10 0xffffffff #11 0xffffffff #12 0xffffffff #13 0xffffffff #14 0xffffffff #15 0xffffffff ##### I have two additional examples based on these derived type modules that work when I only do the writes, with no reads. #####