Consider the following testcase: ! { dg-do run } ! Adapted from fmt_t_6.f testcase for PR 34782 character a(6) data a / 'a', 'b', 'c', 'd', 'e', 'f' / write(*,'(T20,A3, T1,A4, T5,A2, T7,A2, T9,A4, T17,A2)') 1 'a', 'b', 'c', 'd', 'e', 'f' print *, 'should be' write (*, '(A)') " b c d e f a" end
gcc version 4.4.0 20080427 % ./fmtstdout.gf44 a b c d e f should be b c d e f a % ./fmtstdout.gf44 > foo % cat foo b c d e f a should be b c d e f a I stumbled upon this when working on part I of pr 25561. My patch regtests cleanly except for fmt_t_6.f. However with the more strict read/write/seek interface the kind of dirty trick that allowed T edit descriptor to work for seekable streams won't work anymore as we don't have direct access to the buffer. T and TL descriptors are special in that they're the only one that can force us to go backwards in the formatted record. Or are there others? The only way I can think of to fix this would be something like On output, if we encounter a T or TL edit descriptor allocate a temporary buffer, fill it with blanks (' ') create a temporary internal unit, using the above temp buffer as the 'file' do all the formatting to this internal unit when the record is completed copy the contents from the temp internal unit to the real stream deallocate temp unit and buffer On input there are similar concerns, but we already use st_parameter_dt.u.p.line_buffer there. Or then one could of course use line_buffer in the write functions just like they are used for reading. -- Summary: T edit descriptor doesn't work for non-seekable streams Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jb at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36142