public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/16597] New: gfortran: bug in unformatted I/O on scratch files
@ 2004-07-16 21:07 anlauf at hep dot tu-darmstadt dot de
  2004-07-17  0:58 ` [Bug libfortran/16597] " bdavis at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: anlauf at hep dot tu-darmstadt dot de @ 2004-07-16 21:07 UTC (permalink / raw)
  To: gcc-bugs

Hi all,

there's apparently a bug in the runtime when handling unformatted I/O on scratch
files.  It reads back garbage after writing.

Sample program:

      program gfbug4
      implicit none

      integer      strlen
      parameter    (strlen = 4)

      integer      iunit, i, k
      character    string *4

      do 10 i = 1, strlen
         string(i:i) = achar (i)
 10   continue

      iunit = 99
      open (UNIT=iunit,FORM='unformatted',ACCESS='direct',RECL=strlen)
      write (iunit, rec=1) string
      read (iunit, rec=1) i
      close (iunit)
      print *, i

      open (UNIT=iunit,FORM='unformatted',ACCESS='direct',
     $      STATUS='scratch',RECL=strlen)
      write (iunit, rec=1) string
      read (iunit, rec=1) k
      close (iunit)
      print *, k

      if (i .eq. k) then
         print *, 'O.K.'
      else
         print *, '*** Bug! ***'
      endif

      end

Result:

% ./a.out 
    67305985
   538976288
 *** Bug! ***


The first write to fort.99 and reading back works fine - it indicates that
I/O has little-endian form, but the second is just 0x20202020.

-- 
           Summary: gfortran: bug in unformatted I/O on scratch files
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at hep dot tu-darmstadt dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2004-08-27  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-16 21:07 [Bug fortran/16597] New: gfortran: bug in unformatted I/O on scratch files anlauf at hep dot tu-darmstadt dot de
2004-07-17  0:58 ` [Bug libfortran/16597] " bdavis at gcc dot gnu dot org
2004-08-26  2:34 ` bdavis at gcc dot gnu dot org
2004-08-27  7:59 ` cvs-commit at gcc dot gnu dot org
2004-08-27  8:39 ` 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).