This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/16597] New: gfortran: bug in unformatted I/O on scratch files
- From: "anlauf at hep dot tu-darmstadt dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jul 2004 21:07:24 -0000
- Subject: [Bug fortran/16597] New: gfortran: bug in unformatted I/O on scratch files
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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