Bug 19052 - unit 0 not preconnected to standard error
Summary: unit 0 not preconnected to standard error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: David Edelsohn
URL:
Keywords:
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2004-12-17 09:05 UTC by Thomas Koenig
Modified: 2005-01-23 00:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-23 00:24:07


Attachments
connect STDERR_FILENO to Unit 0 (1.28 KB, patch)
2005-01-08 18:43 UTC, David Edelsohn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2004-12-17 09:05:30 UTC
This is different from g77 (and to all
Unix fortran compilers that I know of).

$ cat unit_0.f
      write (0,*) "hello"
      end
$ rm -f fort.0
$ gfortran unit_0.f
$ ./a.out
$ cat fort.0
 hello
$ rm -f fort.0
$ g77 unit_0.f
$ ./a.out
 hello
$ cat fort.0
cat: fort.0: No such file or directory
Comment 1 Andrew Pinski 2004-12-17 12:40:45 UTC
Confirmed.
Comment 2 David Edelsohn 2005-01-08 18:43:16 UTC
Created attachment 7904 [details]
connect STDERR_FILENO to Unit 0
Comment 3 GCC Commits 2005-01-23 00:15:01 UTC
Subject: Bug 19052

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dje@gcc.gnu.org	2005-01-23 00:14:32

Modified files:
	libgfortran    : ChangeLog libgfortran.h 
	libgfortran/io : io.h open.c unit.c unix.c 
	libgfortran/runtime: environ.c 

Log message:
	PR libgfortran/19052
	* libgfortran.h (options_t): Add stderr_unit.
	* io/io.h (error_stream): Declare.
	* io/open.c (new_unit): Do not terminate abnormally if opening
	file preconnected to stdin, stdout, or stderr.
	* io/unit.c (init_units): Initialize stderr_unit.
	* io/unix.c (error_stream): New function.
	* runtime/environ.c (GFORTRAN_STDERR_UNIT): New environment variable.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.150&r2=1.151
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/libgfortran.h.diff?cvsroot=gcc&r1=1.21&r2=1.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/io.h.diff?cvsroot=gcc&r1=1.15&r2=1.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/open.c.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/unit.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/unix.c.diff?cvsroot=gcc&r1=1.20&r2=1.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/runtime/environ.c.diff?cvsroot=gcc&r1=1.6&r2=1.7

Comment 4 David Edelsohn 2005-01-23 00:24:42 UTC
Patch committed.