The following program exposes a problem with the scoping of the loop variable
in the IO statement:

program test
   implicit none
   character(len=100) :: value
   integer, dimension(100) :: intvalues
   integer i

   i = 2
   intvalues = 42
   value = "2 5 69"
   write(*,*) len(trim(value))
   read(value,*,end=20,err=20) (intvalues(i),i=1,100)
20 i=i-1
   !
   ! This should print 1 2 5 69
   !
   write(*,*) i, intvalues(1:3)
   !
   ! This prints the expected output 1 1 100
   !
   i = 1
   intvalues = (/ (i,i=1,100) /)
   print *, i, intvalues(1), intvalues(100)
end program test


-- 
           Summary: Scoping problem in implied do loop in I/O statement
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Magnus dot Hagdorn at marsupium dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32257

Reply via email to