$ cat direct_io_2.f90 
      OPEN (7, ACCESS = 'DIRECT', RECL = 50)
      IRECN = 0
      IREC = 216
      DO I=1,100
        IREC = IREC - 2
        IRECN = IRECN + 1
        WRITE(7, REC = IREC) IRECN
      END DO
      IRECCK = 0
      IREC = 216
      DO I = 1,100
        IREC = IREC - 2
        IRECCK = IRECCK + 1
        READ(7, REC = IREC) IRECN
        IF (IRECN .NE. IRECCK) CALL ABORT
      END DO
      END
$ gfc direct_io_2.f90 && ./a.exe
Abort

The file fort.7 is indeed wrong:

$ xxd -s 9745 fort.7 |head -n 1 
0002611: 0000 0000 000d 0a00 0000 0000 0000 0000  ................
$ xxd -s 9745 linux.fort.7 |head -n 1
0002611: 0000 0000 000a 0000 0000 0000 0000 0000  ................

where linux.fort.7 is obtained by running the same program with a linux gfortran
(for which the testcase passes). The problem is very sensitive to the number of
records writtent and the record length (it disappears if they are too little).

-- 
           Summary: direct access failure
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-mingw32


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

Reply via email to