public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/14942] New: Incorrect results with implied-do loops and list directed I/O
@ 2004-04-13 19:51 gcc-bugzilla at gcc dot gnu dot org
  2004-04-13 20:08 ` [Bug fortran/14942] [gfortran] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-04-13 19:51 UTC (permalink / raw)
  To: gcc-bugs

	
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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-04-25 13:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-13 19:51 [Bug fortran/14942] New: Incorrect results with implied-do loops and list directed I/O gcc-bugzilla at gcc dot gnu dot org
2004-04-13 20:08 ` [Bug fortran/14942] [gfortran] " pinskia at gcc dot gnu dot org
2004-04-13 20:08 ` pinskia at gcc dot gnu dot org
2004-04-14  1:31 ` bdavis9659 at comcast dot net
2004-04-16  7:46 ` [Bug libfortran/14942] " pinskia at gcc dot gnu dot org
2004-04-16  7:53 ` bdavis9659 at comcast dot net
2004-04-25  6:42 ` bdavis9659 at comcast dot net
2004-04-25 13:35 ` cvs-commit at gcc dot gnu dot org
2004-04-25 13:38 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).