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
proposed patch: http://gcc.gnu.org/ml/fortran/2005-02/msg00182.html
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
Fixed.
Fixed in 4.1.0, waiting for 4.0 to reopen.
Re-open to bug report, so patch gets committed to 4.0.1
Patch was never committed to 4.0.
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
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