https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105361
Bug ID: 105361 Summary: Incorrect end-of-file condition for derived-type I/O Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- The following test case module x implicit none type foo real :: r end type foo interface read(formatted) module procedure read_formatted end interface read(formatted) contains subroutine read_formatted (dtv, unit, iotype, vlist, iostat, iomsg) class (foo), intent(inout) :: dtv integer, intent(in) :: unit character (len=*), intent(in) :: iotype integer, intent(in) :: vlist(:) integer, intent(out) :: iostat character (len=*), intent(inout) :: iomsg read (unit,*,iostat=iostat,iomsg=iomsg) dtv%r print *,dtv%r end subroutine read_formatted end module x program main use x implicit none type(foo) :: a, b read (*,*) a, b print *,a,b end program main yields, when invoked with $ echo "1 2" | ./a.out 1.00000000 2.00000000 At line 25 of file test.f90 (unit = 5, file = 'stdin') Fortran runtime error: End of file [...] The end-of-file condition is incorrect. The print statement in read_formatted is there just to show the input is read correctly.