[Bug fortran/49296] New: [4.6/4.7 Regression] Wrong I/O END OF FILE

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 6 06:16:00 GMT 2011


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

           Summary: [4.6/4.7 Regression] Wrong I/O END OF FILE
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: jvdelisle@gcc.gnu.org


Reported by Reinhold Bader (LRZ). The following program prints with gfortran
4.5 (and ifort 11, NAG 5.1, g95, pathf95):
 OK

With gfortran 4.6/4.7, it prints:

At line 11 of file read_listdir_01_pos.f90 (unit = 20, file = 'read.dat')
Fortran runtime error: End of file


--------- C part of the test program -----------

#include <stdio.h>

void genfil() {
    FILE *fp;

    fp = fopen("read.dat", "w+");
    fprintf(fp, "abcd efgh");
    fclose(fp);
}


--------- Fortran part of the test program -----------

program read_listdir_01_pos
  implicit none
  integer, parameter :: strmx = 255
  character(len=strmx) :: s1, s2
  interface
     subroutine genfil() bind(c)
     end subroutine genfil
  end interface
  call genfil()
  open(unit=20, file='read.dat', form='FORMATTED', action='READ', status='OLD')
  read(20, fmt=*) s1, s2
  if (trim(s1) == "abcd" .and. trim(s2) == "efgh") then
     write(*, *) 'OK'
  else
     write(*, *) 'FAIL'
  end if
  close(20)
end program read_listdir_01_pos



More information about the Gcc-bugs mailing list