public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/14942] New: Incorrect results with implied-do loops and list directed I/O
Date: Tue, 13 Apr 2004 19:51:00 -0000	[thread overview]
Message-ID: <20040413190103.14942.kargl@c-67-168-59-70.client.comcast.net> (raw)

	
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


             reply	other threads:[~2004-04-13 19:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-13 19:51 gcc-bugzilla at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040413190103.14942.kargl@c-67-168-59-70.client.comcast.net \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).