------- Comment #30 from tkoenig at gcc dot gnu dot org 2007-12-02 20:11 ------- (In reply to comment #25) > Created an attachment (id=14682) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14682&action=view) [edit] > New patch, clean fix.
Yes, this looks clean and self-contained (and something we can safely incorporate into 4.3). Although not strictly a regression-fix, I think this should also be considered for 4.2. This is now regtesting on my machine. > Answer to comment #18, Thomas, the flush is needed for streamio_12.f90 where > we > use a write(10, pos=1) to reposition the file somewhere far from the current > buffer contents. I understand that. What I meant to ask is: Why do we still flush for formatted stream I/O? > Status since comment#24. Two regressions have led me to back away and take a > different approach. I would still like to revisit the unix.c internals later. Probably not in time for 4.3, but this should be on the list for 4.4 (unless we stumble across a bug). I'll try some stress-tests :-) In general: Your patch does the right thing for both reading and writing, as evidenced by the strace log: $ cat readwrite.f90 program main implicit none integer :: i integer(kind=1) r open(95,form="unformatted",access="stream") do i=0,10 write(95) int(i,kind=1) end do close (95) open(95,form="unformatted",access="stream") do i=0,10 read(95) r end do end program main $ gfortran readwrite.f90 $ strace -e write,read,_llseek ./a.out read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`\311\0"..., 512) = 512 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`4\0\000"..., 512) = 512 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\30"..., 512) = 512 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260a\1"..., 512) = 512 _llseek(0, 0, 0xbff954a0, SEEK_CUR) = -1 ESPIPE (Illegal seek) _llseek(1, 0, 0xbff95490, SEEK_CUR) = -1 ESPIPE (Illegal seek) _llseek(2, 0, 0xbff95490, SEEK_CUR) = -1 ESPIPE (Illegal seek) _llseek(3, 0, [0], SEEK_CUR) = 0 write(3, "\0\1\2\3\4\5\6\7\10\t\n", 11) = 11 _llseek(3, 0, [0], SEEK_CUR) = 0 read(3, "\0\1\2\3\4\5\6\7\10\t\n", 8192) = 11 read(3, "", 8181) = 0 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33985