public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows
@ 2013-06-17  8:52 burnus at gcc dot gnu.org
  2013-06-17  8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-17  8:52 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-20 10:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17  8:52 [Bug fortran/57633] New: I/O: Problem with formatted read: reading an incomplete record under Windows burnus at gcc dot gnu.org
2013-06-17  8:55 ` [Bug fortran/57633] I/O: Problem with formatted read: reading CR-LF files (\r\n) burnus at gcc dot gnu.org
2013-06-17  9:20 ` dominiq at lps dot ens.fr
2013-06-18  1:38 ` jvdelisle at gcc dot gnu.org
2013-06-20  8:44 ` burnus at gcc dot gnu.org
2013-06-20  9:12 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org
2013-06-20 10:55 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).