public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file
@ 2007-04-17 15:47 michael dot a dot richmond at nasa dot gov
2007-04-17 19:00 ` [Bug libfortran/31607] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: michael dot a dot richmond at nasa dot gov @ 2007-04-17 15:47 UTC (permalink / raw)
To: gcc-bugs
When I compile and run the following program:
"Hello world" precedes the directory listing if standard output goes to the
console
"Hello world" follows the directory listing if standard output is redirected to
a file
g95 avoids this inconsistency by flushing all buffers before executing "CALL
SYSTEM"
PROGRAM test_system
PRINT *, "Hello world"
CALL SYSTEM("ls")
END PROGRAM test_system
--
Summary: CALL SYSTEM produces garbled output when writing to a
buffered file
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: michael dot a dot richmond at nasa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/31607] CALL SYSTEM produces garbled output when writing to a buffered file
2007-04-17 15:47 [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file michael dot a dot richmond at nasa dot gov
@ 2007-04-17 19:00 ` pinskia at gcc dot gnu dot org
2007-04-18 5:03 ` jvdelisle at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-17 19:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-04-17 20:00 -------
This is a standard problem even with C code so I don't see why this is specific
to fortran or any language.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|fortran |libfortran
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/31607] CALL SYSTEM produces garbled output when writing to a buffered file
2007-04-17 15:47 [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file michael dot a dot richmond at nasa dot gov
2007-04-17 19:00 ` [Bug libfortran/31607] " pinskia at gcc dot gnu dot org
@ 2007-04-18 5:03 ` jvdelisle at gcc dot gnu dot org
2007-05-07 8:59 ` fxcoudert at gcc dot gnu dot org
2007-05-07 10:37 ` fxcoudert at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-04-18 5:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jvdelisle at gcc dot gnu dot org 2007-04-18 06:03 -------
I can confirm this behavior. Putting a flush(6) before the call fixes this, so
it is within the language to handle this. I am marking this as minor and I
will get to it after a few other things I need to get done first. :)
--
jvdelisle at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-04-18 06:03:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/31607] CALL SYSTEM produces garbled output when writing to a buffered file
2007-04-17 15:47 [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file michael dot a dot richmond at nasa dot gov
2007-04-17 19:00 ` [Bug libfortran/31607] " pinskia at gcc dot gnu dot org
2007-04-18 5:03 ` jvdelisle at gcc dot gnu dot org
@ 2007-05-07 8:59 ` fxcoudert at gcc dot gnu dot org
2007-05-07 10:37 ` fxcoudert at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-05-07 8:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2007-05-07 09:59 -------
Tentative patch:
Index: intrinsics/system.c
===================================================================
--- intrinsics/system.c (revision 124460)
+++ intrinsics/system.c (working copy)
@@ -49,6 +49,9 @@ system_sub (const char *fcmd, GFC_INTEGE
char cmd[cmd_len + 1];
int stat;
+ /* Flush all I/O units before executing the command. */
+ flush_all_units();
+
memcpy (cmd, fcmd, cmd_len);
cmd[cmd_len] = '\0';
Index: libgfortran.h
===================================================================
--- libgfortran.h (revision 124460)
+++ libgfortran.h (working copy)
@@ -658,6 +658,11 @@ internal_proto(fstrcpy);
extern void cf_strcpy (char *, int, const char *);
internal_proto(cf_strcpy);
+/* io/intrinsics.c */
+
+extern void flush_all_units (void);
+internal_proto(flush_all_units);
+
/* io.c */
extern void init_units (void);
Index: io/io.h
===================================================================
--- io/io.h (revision 124460)
+++ io/io.h (working copy)
@@ -586,9 +586,6 @@ internal_proto(compare_file_filename);
extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
internal_proto(find_file);
-extern void flush_all_units (void);
-internal_proto(flush_all_units);
-
extern int stream_at_bof (stream *);
internal_proto(stream_at_bof);
Are there other similar cases of intrinsics where we'd better FLUSH units
before using them.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libfortran/31607] CALL SYSTEM produces garbled output when writing to a buffered file
2007-04-17 15:47 [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file michael dot a dot richmond at nasa dot gov
` (2 preceding siblings ...)
2007-05-07 8:59 ` fxcoudert at gcc dot gnu dot org
@ 2007-05-07 10:37 ` fxcoudert at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-05-07 10:37 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2007-
| |05/msg00392.html
Status|NEW |ASSIGNED
Last reconfirmed|2007-04-18 06:03:29 |2007-05-07 11:37:42
date| |
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-05-07 10:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-17 15:47 [Bug fortran/31607] New: CALL SYSTEM produces garbled output when writing to a buffered file michael dot a dot richmond at nasa dot gov
2007-04-17 19:00 ` [Bug libfortran/31607] " pinskia at gcc dot gnu dot org
2007-04-18 5:03 ` jvdelisle at gcc dot gnu dot org
2007-05-07 8:59 ` fxcoudert at gcc dot gnu dot org
2007-05-07 10:37 ` fxcoudert 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).