This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/39587] Reading integer from "" gives end-of-file instead of reading a 0
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Apr 2009 08:09:04 -0000
- Subject: [Bug fortran/39587] Reading integer from "" gives end-of-file instead of reading a 0
- References: <bug-39587-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from burnus at gcc dot gnu dot org 2009-04-14 08:09 -------
> I think gfortran has this right. This is an attempt to read from an internal
> unit of length zero. Try the same operation from a zero length file.
I'm not sure whether gfortran is right, but my program from comment 0 works
with NAG f95, ifort, sunf95, openf95, g95, pathf95, pgf95 - and only fails with
gfortran.
The following program (using a zero-length file) works with all of the
compilers above - and it also works with gfortran:
implicit none
character(len=5) :: str
integer :: a
str = ''
a = 5
open(16,form='formatted')
write(16,'(a)') ''
rewind(16)
read(16,'(5x,i1)') a
close(16,status='delete')
print *, a
if(a /= 0) stop 'Error'
end
* * *
The following vendor extension would be nice; it works with ifort, sunf95,
openf95, pgf95, pathf95:
implicit none
character(len=5) :: str
logical :: a
str = ''
a = .true.
read(str,'(L1)') a ! Extension: Blanks are read as .false.
print *, a
if(a .neqv. .false.) stop 'error'
end
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39587