On 7/22/24 8:13 AM, Jerry D wrote:
Hi all,
The attached patch fixes this by avoiding looking for and avoiding the
EOF condition in the parent READ after returning from the child IO process.
I could not think of a simple test case yet since the problem occurred
only when redirecting the input to the test program via a pipe. If I
have some more time today I will try to come up with something.
OK for mainline?
Jerry
commit e6fa9d84cf126630c9ea744aabec6d7715087310 (HEAD -> master)
Author: Jerry DeLisle <jvdeli...@gcc.gnu.org>
Date: Sun Jul 21 19:19:00 2024 -0700
Fortran: Suppress wrong End Of File error with user defined IO.
libgfortran/ChangeLog:
PR libfortran/105361
* io/list_read.c (finish_list_read): Add a condition check for
a user defined derived type IO operation to avoid calling the
EOF error.
I failed to mention that this patch regression tests OK on x86_64.
I also developed the attached test case. This does reproduce the error.
I will update the log entry to reflect this test case.
OK for mainline?
! { dg-do run }
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
real :: c, d
open(10, access="stream")
write(10) "1 2" ! // NEW_LINE('A')
close(10)
open(10)
read(10,*) c, d
if ((c /= 1.0) .or. (d /= 2.0)) stop 1
rewind(10)
!print *, c,d
read (10,*) a, b
close(10, status="delete")
if ((a%r /= 1.0) .or. (b%r /= 2.0)) stop 2
!print *, a,b
end program main