public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
@ 2007-10-22 18:59 ` dir at lanl dot gov
  2007-10-22 19:00 ` dir at lanl dot gov
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dir at lanl dot gov @ 2007-10-22 18:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dir at lanl dot gov  2007-10-22 18:59 -------
Created an attachment (id=14389)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14389&action=view)
The fortran source


-- 


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


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

* [Bug libfortran/33863]  New: backspace error on i386-pc-mingw32
@ 2007-10-22 18:59 dir at lanl dot gov
  2007-10-22 18:59 ` [Bug libfortran/33863] " dir at lanl dot gov
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: dir at lanl dot gov @ 2007-10-22 18:59 UTC (permalink / raw)
  To: gcc-bugs

When I compile and run this program under MSYS, I get a read error. The program
reads and prints the input file and then backspaces the file to read it again.
This program fails on MSYS. Works on the Macintosh and everywhere else that I
have tried it.


$ gfortran -o main main.f

rantad@XP-RANTAD ~/junk
$ main <t33 >out1
At line 20 of file main.f (unit = 5, file = 'stdin')
Fortran runtime error: Bad value during integer read

rantad@XP-RANTAD ~/junk
$ gfortran --v
Using built-in specs.
Target: i386-pc-mingw32
Configured with: ../trunk/configure --prefix=/mingw
--enable-languages=c,fortran --with-gmp=/home/FX/local --with-ld=/mingw/bin/ld
--with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads
--disable-nls --build=i386-pc-mingw32 --enable-libgomp --disable-shared
Thread model: win32
gcc version 4.3.0 20070905 (experimental) [trunk revision 128128] (GCC) 

rantad@XP-RANTAD ~/junk


-- 
           Summary: backspace error on i386-pc-mingw32
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dir at lanl dot gov
  GCC host triplet: i386-pc-mingw32


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
  2007-10-22 18:59 ` [Bug libfortran/33863] " dir at lanl dot gov
@ 2007-10-22 19:00 ` dir at lanl dot gov
  2007-10-22 23:11 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dir at lanl dot gov @ 2007-10-22 19:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dir at lanl dot gov  2007-10-22 19:00 -------
Created an attachment (id=14390)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14390&action=view)
The input file


-- 


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
  2007-10-22 18:59 ` [Bug libfortran/33863] " dir at lanl dot gov
  2007-10-22 19:00 ` dir at lanl dot gov
@ 2007-10-22 23:11 ` jvdelisle at gcc dot gnu dot org
  2007-10-30  4:19 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-10-22 23:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2007-10-22 23:10 -------
I will work this, maybe a cr-lf issue.


-- 

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-10-22 23:10:54
               date|                            |


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (2 preceding siblings ...)
  2007-10-22 23:11 ` jvdelisle at gcc dot gnu dot org
@ 2007-10-30  4:19 ` jvdelisle at gcc dot gnu dot org
  2007-10-30 12:59 ` dir at lanl dot gov
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-10-30  4:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2007-10-30 04:19 -------
I can reproduce this.  Don't see the problem yet. :)


-- 


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (3 preceding siblings ...)
  2007-10-30  4:19 ` jvdelisle at gcc dot gnu dot org
@ 2007-10-30 12:59 ` dir at lanl dot gov
  2007-11-04 21:25 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dir at lanl dot gov @ 2007-10-30 12:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dir at lanl dot gov  2007-10-30 12:58 -------
      Hi Jerry,

      Thanks for looking at the problem. I am actually having several failures
with GFORTRAN on CYGWIN and MSYS (All, I/O problems perhaps). This was the
first that I was able to isolate. I am hoping that the other problems will go
away with it.


-- 


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (4 preceding siblings ...)
  2007-10-30 12:59 ` dir at lanl dot gov
@ 2007-11-04 21:25 ` jvdelisle at gcc dot gnu dot org
  2007-11-08 19:56 ` dir at lanl dot gov
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-11-04 21:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2007-11-04 21:25 -------
OK, I have taken some time to investigate this.  The problem is not MSYS
specific and also occurs with Cygwin.

I do not think we can fix this. Its not a gfortran bug.

The code is attempting to backspace a standard input stream.  You can not seek
backwards on an input stream.  The code happens to work in some cases because
input buffering happens to still contain the relevant data. Gfortran buffering
hides the stream but you can not rely on it depending on how far you have to
backspace

If I modify the code slightly and open the input file directly, it works
without error.  This tels me its not a CR-LF issue.  Any other opinions?


-- 


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (5 preceding siblings ...)
  2007-11-04 21:25 ` jvdelisle at gcc dot gnu dot org
@ 2007-11-08 19:56 ` dir at lanl dot gov
  2007-11-08 23:51 ` fxcoudert at gcc dot gnu dot org
  2007-11-23 17:15 ` jvdelisle at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: dir at lanl dot gov @ 2007-11-08 19:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dir at lanl dot gov  2007-11-08 19:56 -------
When I changed it to directly open the file, it was happy. You are right, of
course, backspacing a stream file is not permitted. However, most run time
libraries do the simple thing when they see io-redirection - they close the
stream file and re-open it as a ordinary file. Is there any reason GFORTRAN
could not do that ?


-- 


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (6 preceding siblings ...)
  2007-11-08 19:56 ` dir at lanl dot gov
@ 2007-11-08 23:51 ` fxcoudert at gcc dot gnu dot org
  2007-11-23 17:15 ` jvdelisle at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-11-08 23:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from fxcoudert at gcc dot gnu dot org  2007-11-08 23:51 -------
(In reply to comment #7)
> However, most run time
> libraries do the simple thing when they see io-redirection - they close the
> stream file and re-open it as a ordinary file. Is there any reason GFORTRAN
> could not do that ?

As a generic answer: I don't think it's advisable as it's against the principle
of least surprise. I can think of at least a standard case where this could
fail: you create a file, run a Fortran program with stdin redirected to that
file, and unlink the file (so that, when the Fortran program exits, the file is
removed without you having to wait and do it later). In that case, trying to
reopen it will fail (it might even give wrong results if a new file of the same
name is created, though it's not likely).

This "unlink" trick is widely used. For example, my shell (zsh) does it to
avoid you creating temporary files: instead of letting you do:

$ ./foo > tmp
$ ./bar < tmp

you can do

$ ./bar =(./foo)

(and yes, you could use a pipe, but it's not the same if tmp is large and you
don't want the two programs to run concurrently).

Well, I really am verbose tonight, but I don't think it's desirable.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org


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


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

* [Bug libfortran/33863] backspace error on i386-pc-mingw32
  2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
                   ` (7 preceding siblings ...)
  2007-11-08 23:51 ` fxcoudert at gcc dot gnu dot org
@ 2007-11-23 17:15 ` jvdelisle at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-11-23 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jvdelisle at gcc dot gnu dot org  2007-11-23 17:14 -------
I decided to close this because of FX comment as well as I think it is not
valid to backspace on a non-seekable stream


-- 

jvdelisle at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-11-23 17:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-22 18:59 [Bug libfortran/33863] New: backspace error on i386-pc-mingw32 dir at lanl dot gov
2007-10-22 18:59 ` [Bug libfortran/33863] " dir at lanl dot gov
2007-10-22 19:00 ` dir at lanl dot gov
2007-10-22 23:11 ` jvdelisle at gcc dot gnu dot org
2007-10-30  4:19 ` jvdelisle at gcc dot gnu dot org
2007-10-30 12:59 ` dir at lanl dot gov
2007-11-04 21:25 ` jvdelisle at gcc dot gnu dot org
2007-11-08 19:56 ` dir at lanl dot gov
2007-11-08 23:51 ` fxcoudert at gcc dot gnu dot org
2007-11-23 17:15 ` 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).