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

            Bug ID: 102699
           Summary: Stream access input/output
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xin....@compiler-dev.com
  Target Milestone: ---

Consider the following Fortran program:
!------------------------
program streamio
  implicit none
  integer :: k(5) = [5_4, 4_4, 3_4, 2_4, 1_4]

  open(10, file="123.txt", form="formatted", access="stream")
!  open(10, file="123.txt", form="formatted")

  write(10, "(A6)") '098765'
  write(10, "(A6)") '239345'
  write(10, "(A6)") '123789'
  write(10, "(A6)") '789509'
  write(10, "(A6)") '543210'

  rewind(10)

  read(10, "(I2)") k(1)
  read(10, "(I3)") k(2)
  read(10, "(I2)") k(3)
  read(10, "(I3)") k(4)
  read(10, "(I1)") k(5)

  print *,k
end program
!------------------------

Compiled with gfortran 10.1.0.

Regardless of whether the access uses "stream",the result is the same.

the result:

           9         239          12         789           5

the file: 
098765
239345
123789
789509
543210

IMHO, when using access="stream", the result should be 
           9         876          52         393           4
and the file shoule be
098765239345123789789509543210

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

Reply via email to