https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105456

            Bug ID: 105456
           Summary: Child I/O does not propage iostat
           Product: gcc
           Version: unknown
            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 program

module sk1
  implicit none
  type char
     character :: ch
  end type char
  interface read (formatted)
     module procedure read_formatted
  end interface read (formatted)
contains
  subroutine read_formatted (dtv, unit, iotype, vlist, iostat, iomsg)
    class (char), 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
    character :: ch
    read (unit,fmt='(A1)', advance="no", iostat=iostat, iomsg=iomsg) ch
    iostat = 42
    dtv%ch = ch
  end subroutine read_formatted
end module sk1

program skip1
  use sk1
  implicit none
  type (char) :: x
  open (10,status="scratch")
  write (10,'(A)') '', 'a'
  rewind (10)
  read (10,*) x
  write (*,'(10(A))') "Read: '",x%ch,"'"
end program skip1

runs to completion, but it should propagate the iostat to the
caller and error out on the read.

Reply via email to