[patch] fix PR libfortran/23321

Paul Thomas paulthomas2@wanadoo.fr
Thu Aug 18 18:25:00 GMT 2005


Thomas,

The patch looks OK. However, I have a problem with the test-case: Unless 
the print statement is present, it aborts at the next statement.  I 
cannot, at the moment, see what the problem is.

GNU F95 version 4.1.0 20050813 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3).

! { dg-do run }
! PR 23321 : Running off the end of a file was not detected with direct I/O.
program main
  implicit none
  integer(kind=1) :: a, b
  integer :: ios, i

  a = 42
  b = 1
  open (unit=10,status="scratch",recl=1,access="direct")
  write(10,rec=1) a

  read (10,rec=2, iostat=ios) b
  if (ios == 0) call abort

  read (10, rec=82641, iostat=ios) b      ! This used to cause a segfault
  print *, a, b, ios                      ! THIS IS NECESSARY TO PREVENT 
ABORT
  if (ios == 0) call abort

  read(10, rec=1, iostat=ios) b
  if (ios /= 0) call abort
  if (a /= b) call abort

end program main

Regards

Paul T



More information about the Fortran mailing list