$ cat tst.f90
program main
  real :: a
  integer :: ios
  open (10, pad='no')
  write (10, '(A)') '1','1'
  rewind (10)
  read (10,'(I2)',iostat=ios) i
  ios = -4321
  read (10, '(I1)', iostat=ios) i
  print *,ios
end program main
$ gfortran tst.f90
$ ./a.out
       -4321

Here's a patch:

Index: lock.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/lock.c,v
retrieving revision 1.8
diff -c -p -r1.8 lock.c
*** lock.c      17 Aug 2005 02:48:56 -0000      1.8
--- lock.c      27 Aug 2005 22:10:48 -0000
*************** library_start (void)
*** 54,60 ****
       stay within the library. */
    g.in_library = 1;

!   if (ioparm.iostat != NULL && ioparm.library_return == LIBRARY_OK)
      *ioparm.iostat = ERROR_OK;

    ioparm.library_return = LIBRARY_OK;
--- 54,60 ----
       stay within the library. */
    g.in_library = 1;

!   if (ioparm.iostat != NULL)
      *ioparm.iostat = ERROR_OK;

    ioparm.library_return = LIBRARY_OK;

-- 
           Summary: iostat handling after library error return
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23598

Reply via email to