[Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 17 08:52:00 GMT 2013


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

            Bug ID: 57633
           Summary: I/O: Problem with formatted read: reading an
                    incomplete record under Windows
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jb at gcc dot gnu.org, jvdelisle at gcc dot gnu.org

The following seems to be a Windows only problem as I cannot reproduce it under
Linux. See
https://groups.google.com/forum/?fromgroups#!topic/comp.lang.fortran/mtERtiPKqu0


testcase.txt file:

line1,1,
line2


Produces the following output
  line1                1
                       0

Expected:
  line1                1
  line2                5

Comment by BAF:
------------------------------------------------------------
"I can confirm these result with the exact same program under mingw32
gfortran 4.8.0 20130302 (experimental) [trunk revision 196403].

To eliminate the concern about the end of line/record character for the
second line of the file, I added a third line, so that the data file is now

line1,1,
line2
line3

The output remains the same, i.e.

  line1                1
                       0

Very strange.  If I change the second read statement to be be

   read(11,*)s1

(i.e., change the formatted read to a list directed form), the output
changes to what would be expected in either case

  line1                1
  line2                5

Seems like the "bug" is related to the formatted read. 
------------------------------------------------------------


Test program:

program teststuff
  implicit none
  integer::a
  character(len=10)::s1
  open(11,file="testcase.txt")
  read(11,*)s1,a
  write(*,*)s1,a
  read(11,"(a)")s1
  write(*,*)s1, len_trim(s1)
end program teststuff



More information about the Gcc-bugs mailing list