https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102699

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to xin liu from comment #0)

> 
> is it a bug or is there something wrong with my understanding?

I think you may be tripped up by "12.3.3.4 Stream access" where
one finds

P. 213

  While connected for formatted stream access, an external file has
  the following properties.

  *  Some file storage units of the file can contain record markers;
     this imposes a record structure on the file in addition to its
     stream structure. There might or might not be a record marker
     at the end of the file.  If there is no record marker at the end
     of the file, the final record is incomplete.

Followed by "12.3.4.2 Advancing and nonadvancing input/output"

P. 214

   An advancing input/output statement always positions a record
   file after the last record read or written, unless there is an
   error condition.

If I trim your program to

  program streamio
  implicit none
  open(10, file="123.txt", access="stream")
  write(10) '098765'
  write(10) '239345'
  write(10) '123789'
  write(10) '789509'
  write(10) '543210'
  close(10)
  end


the resulting filesize for 123.txt is 30 bytes.   If, instead, I use

  program streamio
  implicit none
  open(10, file="123.txt", form="formatted", access="stream")
  write(10, "(A6)") '098765'
  write(10, "(A6)") '239345'
  write(10, "(A6)") '123789'
  write(10, "(A6)") '789509'
  write(10, "(A6)") '543210'
  close(10)
  end

the resulting filesize for 123.txt is 35 bytes.  So, record markers
are written into the file.  You can probably verify this by using
INQUIRE and POS= after the READs in your original code to see if 
the file is positioned at the start of a record.

Reply via email to