The following test case reads past the end of record because sf_read is being
executed before the check for length is performed.  Discovered during testing
of arrayio.  See message: http://gcc.gnu.org/ml/fortran/2005-10/msg00382.html

The following simplified test case shows the problem without using my arrayio
patches not yet committed.

program read_block
  character*4, dimension(8) :: abuf = (/"0123","4567","89AB","CDEF", &
                                        "0123","4567","89AB","CDEF"/)
  character*4, dimension(2,4) :: buf
  character*8 :: a
  equivalence (buf,abuf)
  read(buf, '(a8)') a
  print *, a
end program read_block

gfortran gives:

$ ./a.out
 01234567

ifort gives:

$ ./a.out
 0123


-- 
           Summary: read_block wrong execution order
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: jvdelisle at gcc dot gnu dot org
        ReportedBy: jvdelisle at gcc dot gnu dot org


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

Reply via email to