public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33307]  New: I/O read/positioning problem
@ 2007-09-04 19:58 anlauf at gmx dot de
  2007-09-04 20:00 ` [Bug fortran/33307] " anlauf at gmx dot de
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2007-09-04 19:58 UTC (permalink / raw)
  To: gcc-bugs

The attached program exhibits a strange problem with gfortran
when repeatedly trying to position within an input file,
and which I have been hunting for a long time.
The program is supposed to work as follows:

- open input file
- do
-   rewind
-   repeatedly search for lines containing a special text
- end do

The program always succeeds in finding the occurence of the
first text, but fails to find the second text if the first
text does *not* occur on the first text line.

Example 1:
% cat gfcbug69.nml 
! ***Remove this line***
&FOO        file='foo' /
&BAR        file='bar' /
% gfc -g -Wall -std=f2003 gfcbug69.f90
% ./a.out 
inquire: after OPEN: position = ASIS      nextrec = 0
 ------------------------------------------------------------------
inquire: after REWIND: position = REWIND    nextrec = 0

position_nml: Scanning for: FOO
position_nml: SUCCESS!  line= &FOO        file='foo' /
inquire: after position_nml: position = ASIS      nextrec = 0

 *** Found: &FOO        file='foo' /

position_nml: Scanning for: FOO
position_nml: FAIL: ios=   -1
inquire: after position_nml: position = APPEND    nextrec = 0
 ------------------------------------------------------------------
inquire: after REWIND: position = REWIND    nextrec = 0

position_nml: Scanning for: BAR
position_nml: FAIL: ios=   -1
inquire: after position_nml: position = REWIND    nextrec = 0
 ------------------------------------------------------------------


Removing the indicated line from the text file leads to:
% ./a.out
inquire: after OPEN: position = ASIS      nextrec = 0
 ------------------------------------------------------------------
inquire: after REWIND: position = REWIND    nextrec = 0

position_nml: Scanning for: FOO
position_nml: SUCCESS!  line= &FOO        file='foo' /
inquire: after position_nml: position = REWIND    nextrec = 0

 *** Found: &FOO        file='foo' /

position_nml: Scanning for: FOO
position_nml: FAIL: ios=   -1
inquire: after position_nml: position = APPEND    nextrec = 0
 ------------------------------------------------------------------
inquire: after REWIND: position = REWIND    nextrec = 0

position_nml: Scanning for: BAR
position_nml: SUCCESS!  line= &BAR        file='bar' /
inquire: after position_nml: position = ASIS      nextrec = 0

 *** Found: &BAR        file='bar' /

position_nml: Scanning for: BAR
position_nml: FAIL: ios=   -1
inquire: after position_nml: position = ASIS      nextrec = 0
 ------------------------------------------------------------------


Comparing the two results shows:
% diff -u out.fail out.success
--- out.fail    2007-09-04 21:31:22.000000000 +0200
+++ out.success 2007-09-04 21:31:14.000000000 +0200
@@ -4,7 +4,7 @@

 position_nml: Scanning for: FOO
 position_nml: SUCCESS!  line= &FOO        file='foo' /
-inquire: after position_nml: position = ASIS      nextrec = 0
+inquire: after position_nml: position = REWIND    nextrec = 0

  *** Found: &FOO        file='foo' /

@@ -15,6 +15,12 @@
 inquire: after REWIND: position = REWIND    nextrec = 0

 position_nml: Scanning for: BAR
+position_nml: SUCCESS!  line= &BAR        file='bar' /
+inquire: after position_nml: position = ASIS      nextrec = 0
+
+ *** Found: &BAR        file='bar' /
+
+position_nml: Scanning for: BAR
 position_nml: FAIL: ios=   -1
-inquire: after position_nml: position = REWIND    nextrec = 0
+inquire: after position_nml: position = ASIS      nextrec = 0
  ------------------------------------------------------------------


For some reason the file position after attempting to find the second
text is still "REWIND".  This may only be a cosmetic problem, but
it could be a hint towards the source of the problem.


-- 
           Summary: I/O read/positioning problem
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at gmx dot de
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
@ 2007-09-04 20:00 ` anlauf at gmx dot de
  2007-09-05  0:11 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2007-09-04 20:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from anlauf at gmx dot de  2007-09-04 20:00 -------
Created an attachment (id=14156)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14156&action=view)
Demo code

Use with the file "gfcbug69.nml" from the bug description (3 lines),
and compare with a run with the first line of "gfcbug69.nml" removed.


-- 


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
  2007-09-04 20:00 ` [Bug fortran/33307] " anlauf at gmx dot de
@ 2007-09-05  0:11 ` jvdelisle at gcc dot gnu dot org
  2007-09-05 21:10 ` anlauf at gmx dot de
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-05  0:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-09-05 00:11 -------
I have been waiting for this to emerge.  We knew there was a problem somewhere.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-05 00:11:16
               date|                            |


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
  2007-09-04 20:00 ` [Bug fortran/33307] " anlauf at gmx dot de
  2007-09-05  0:11 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-05 21:10 ` anlauf at gmx dot de
  2007-09-07 17:55 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gmx dot de @ 2007-09-05 21:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from anlauf at gmx dot de  2007-09-05 21:09 -------
Created an attachment (id=14161)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14161&action=view)
Alternative demo code

This reduced variant shows that reading fails after the second rewind.

With the same 3-line input file gfcbug69.nml I now get:

inquire: after OPEN: position = ASIS      nextrec = 0

 k =           1
inquire: after REWIND: position = REWIND    nextrec = 0
1: read: ! ***Remove this line***
2: read: &FOO        file='foo' /
inquire: after read_lines (2): position = ASIS      nextrec = 0
inquire: after BACKSPACE: position = ASIS      nextrec = 0
1: read: &FOO        file='foo' /
2: read: &BAR        file='bar' /
inquire: after read_lines (many): position = APPEND    nextrec = 0
inquire: after BACKSPACE: position = APPEND    nextrec = 0

 k =           2
inquire: after REWIND: position = REWIND    nextrec = 0
inquire: after read_lines (2): position = REWIND    nextrec = 0
inquire: after BACKSPACE: position = REWIND    nextrec = 0
inquire: after read_lines (many): position = REWIND    nextrec = 0
inquire: after BACKSPACE: position = REWIND    nextrec = 0


During the second execution of the loop body no lines are read.


-- 


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
                   ` (2 preceding siblings ...)
  2007-09-05 21:10 ` anlauf at gmx dot de
@ 2007-09-07 17:55 ` jvdelisle at gcc dot gnu dot org
  2007-09-07 20:16 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-07 17:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2007-09-07 17:54 -------
Harold,

As a work around, try putting a LF at the end of the last line of the input
file.  I am honing on on this, but don't have it yet.


-- 


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
                   ` (3 preceding siblings ...)
  2007-09-07 17:55 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-07 20:16 ` jvdelisle at gcc dot gnu dot org
  2007-09-07 20:24 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-07 20:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2007-09-07 20:16 -------
Subject: Bug 33307

Author: jvdelisle
Date: Fri Sep  7 20:16:05 2007
New Revision: 128253

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128253
Log:
2007-09-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/33307
        * io/filepos.c (st_backspace): Don't truncate when already at the end
        of the file.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/file_pos.c


-- 


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
                   ` (4 preceding siblings ...)
  2007-09-07 20:16 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-07 20:24 ` jvdelisle at gcc dot gnu dot org
  2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
  2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-07 20:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2007-09-07 20:23 -------
Subject: Bug 33307

Author: jvdelisle
Date: Fri Sep  7 20:23:40 2007
New Revision: 128254

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128254
Log:
2007-09-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/33307
        * gfortran.dg/backspace_10.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/backspace_10.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
                   ` (6 preceding siblings ...)
  2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-07 20:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

* [Bug fortran/33307] I/O read/positioning problem
  2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
                   ` (5 preceding siblings ...)
  2007-09-07 20:24 ` jvdelisle at gcc dot gnu dot org
@ 2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
  2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-09-07 20:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2007-09-07 20:27 -------
Fixed on trunk.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2007-09-07 20:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-04 19:58 [Bug fortran/33307] New: I/O read/positioning problem anlauf at gmx dot de
2007-09-04 20:00 ` [Bug fortran/33307] " anlauf at gmx dot de
2007-09-05  0:11 ` jvdelisle at gcc dot gnu dot org
2007-09-05 21:10 ` anlauf at gmx dot de
2007-09-07 17:55 ` jvdelisle at gcc dot gnu dot org
2007-09-07 20:16 ` jvdelisle at gcc dot gnu dot org
2007-09-07 20:24 ` jvdelisle at gcc dot gnu dot org
2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot org
2007-09-07 20:27 ` jvdelisle at gcc dot gnu dot 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).