Bug 19872 - [4.0 only] closed and re-opened file not overwriten
Summary: [4.0 only] closed and re-opened file not overwriten
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2005-02-10 09:56 UTC by Bud Davis
Modified: 2005-09-11 21:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0
Known to fail:
Last reconfirmed: 2005-02-20 06:22:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bud Davis 2005-02-10 09:56:17 UTC
program wtest
      implicit none
      open(1,file='wtest.out')
      write(1,'("1 2 3 4 5 6 7 8 9")')
      close(1)
      open(1,file='wtest.out')
      write(1,'("9 8 7 6")')
      close(1)
      end


[bdavis@localhost gfortran]$ gfc a.f
[bdavis@localhost gfortran]$ ./a.out
[bdavis@localhost gfortran]$ cat wtest.out
9 8 7 6
1 2 3 4 5 6 7 8 9
[bdavis@localhost gfortran]$ g77 a.f
[bdavis@localhost gfortran]$ ./a.out
[bdavis@localhost gfortran]$ cat wtest.out
9 8 7 6
Comment 1 Bud Davis 2005-02-20 03:09:17 UTC
proposed patch:

http://gcc.gnu.org/ml/fortran/2005-02/msg00182.html
Comment 2 GCC Commits 2005-04-10 03:43:15 UTC
Subject: Bug 19872

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kargl@gcc.gnu.org	2005-04-10 03:43:09

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : transfer.c 

Log message:
	PR fortran/19872
	* io/transfer.c (data_transfer_init): truncate an existing
	file on the first write.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.187&r2=1.188
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.34&r2=1.35

Comment 3 kargls 2005-04-10 03:52:41 UTC
Fixed.
Comment 4 Thomas Koenig 2005-04-10 09:36:57 UTC
Fixed in 4.1.0, waiting for 4.0 to reopen.
Comment 5 kargls 2005-04-10 15:14:01 UTC
Re-open to bug report, so patch gets committed to 4.0.1
Comment 6 Thomas Koenig 2005-05-21 20:34:42 UTC
Fixed.
Comment 7 Francois-Xavier Coudert 2005-09-11 18:40:48 UTC
Patch was never committed to 4.0.
Comment 8 GCC Commits 2005-09-11 18:55:25 UTC
Subject: Bug 19872

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	fxcoudert@gcc.gnu.org	2005-09-11 18:55:16

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/io : io.h transfer.c unix.c 
Added files:
	gcc/testsuite/gfortran.dg: overwrite_1.f 

Log message:
	PR libfortran/19872
	* gfortran.dg/overwrite_1.f: New test.
	
	PR libfortran/19872
	PR libfortran/20179
	* io/unix.c (is_preconnected): Add function to test if a stream
	corresponds to a preconnected unit.
	* io/io.h: Add prototype for is_preconnected.
	* io/transfer.c (data_transfer_init): Truncate overwritten files
	on first write, but not preconnected units.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.397&r2=1.5084.2.398
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/overwrite_1.f.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.90&r2=1.163.2.91
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/io.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.16.10.7&r2=1.16.10.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.32.2.16&r2=1.32.2.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/unix.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.21.10.14&r2=1.21.10.15

Comment 9 GCC Commits 2005-09-11 19:39:42 UTC
Subject: Bug 19872

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	fxcoudert@gcc.gnu.org	2005-09-11 19:39:35

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: overwrite_1.f 

Log message:
	PR libfortran/19872
	* gfortran.dg/overwrite_1.f: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6045&r2=1.6046
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/overwrite_1.f.diff?cvsroot=gcc&r1=1.1&r2=1.2