$ cat endfile.f90
integer i
open(unit=10,file='test.dat')
do i=1,5
write (10,'(I4)') i
end do
rewind(10)
close(10)
end
$ gfc endfile.f90 && a && cat test.dat
1
2
3
4
$ xxd test.dat
0000000: 2020 2031 0d0a 2020 2032 0d0a 2020 2033 1.. 2.. 3
0000010: 0d0a 2020 2034 0d0a 20 .. 4..
If you remove the rewind statement, the program behaves correctly, that is we
have a fifth line with " 5" in it.
--
Summary: rewind truncates file
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23262