This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/14942] New: Incorrect results with implied-do loops and list directed I/O


	
The use of list directed I/O and implied-do loops gives incorrect
results.  Consider the program: 

      program d
      implicit none
      integer i, j, m, n, nin
      real x(3,4)
      nin = 1
      open(unit = nin, file = 'd.dat')
      read(nin, fmt = *) n
      write(*,'(A,I2)') 'n = ', n
      do i = 1, 3
         read(nin, fmt = *) (x(i,j), j=1, n)
         write(*, *) (x(i,j), j=1, n)
      end do
      read(nin, fmt = *) m, n
      write(*,'(A,I2,2X,A,I2)') 'm = ', m, 'n = ', n
      do i = 1, m
         read(nin, fmt = *) (x(i,j), j=1, n)
         write(*, *) (x(i,j), j=1, n)
      end do
      end program d

G77 produces the following output

kargl[234] ./d
n =  4
  1.  2.  3.  4.
  1.  2.  3.  4.
  1.  2.  3.  4.
m =  3  n =  4
  1.  2.  3.  4.
  1.  2.  3.  4.
  1.  2.  3.  4.

while gfortran produces

kargl[236] ./d
n =  4
   1.000000        0.000000        2.000000       3.9933076E-34    
   1.000000        0.000000        2.000000       6.1756624E-41    
   1.000000        0.000000        2.000000       4.0700904E-34    
m =  1  n =  3
   1.000000        0.000000        2.000000

Environment:
System: FreeBSD c-67-168-59-70.client.comcast.net 5.2-CURRENT FreeBSD 5.2-CURRENT #3: Sun Mar 28 10:41:35 PST 2004 kargl@c-67-168-59-70.client.comcast.net:/usr/obj/usr/src/sys/HOTRATS i386


	
host: i386-unknown-freebsd5.2
build: i386-unknown-freebsd5.2
target: i386-unknown-freebsd5.2
configured with: ../gcc/configure --prefix=/home/kargl/gcc-ssa/work --disable-libmudflap --enable-languages=c,f95 --with-gmp=/usr/local

How-To-Repeat:

Compile the above program and run.
------- Additional Comments From kargl at c-67-168-59-70 dot client dot comcast dot net  2004-04-13 19:01 -------
Fix:
  An unrealistic workaround is the avoidance of the Fortran construct.

-- 
           Summary: Incorrect results with implied-do loops and list
                    directed I/O
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kargl at c-67-168-59-70 dot client dot comcast dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-freebsd5.2
  GCC host triplet: i386-unknown-freebsd5.2
GCC target triplet: i386-unknown-freebsd5.2


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]