public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39587]  New: Reading integer from "" gives end-of-file instead of reading a 0
@ 2009-03-30 12:59 burnus at gcc dot gnu dot org
  2009-03-30 20:31 ` [Bug fortran/39587] " burnus at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-03-30 12:59 UTC (permalink / raw)
  To: gcc-bugs

The following program works with NAG f95, g95, sunf95, ifort but fails with a
  Fortran runtime error: End of file
in gfortran. I think the program is valid.

---------------------------------
implicit none
character(len=5) :: str
integer :: a
str = ''
a = 5
read(str,'(5x,i1)') a
print *, a
if(a /= 0) call abort()
end
---------------------------------

If one uses a logical value rather than an integer, ifort/openf95/sunf95 print
.false. and g95/NAG f95/gfortran print an error.

I think "" -> .false. is a vendor extension. If I read the standard correctly,
this extension makes the compiler invalid (i.e. the compiler needs to diagnose
this rather than doing something else); however, I might be wrong and this
extension is acceptable.

I asked at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/68cb46bf0e610043

 * * *

See "10.6.1 Numeric editing": "On Input [...] A field containing only blanks is
considered to be zero."

(Such a statement is missing from "10.6.2 Logical editing".)

I did not quickly find the place which allows "" (rather than " ") to be 0 and
not end-of-file. I also did not find the place which requires the end-of-file
error rather allowing for .false.


-- 
           Summary: Reading integer from "" gives end-of-file instead of
                    reading a 0
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

end of thread, other threads:[~2009-12-05  6:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-30 12:59 [Bug fortran/39587] New: Reading integer from "" gives end-of-file instead of reading a 0 burnus at gcc dot gnu dot org
2009-03-30 20:31 ` [Bug fortran/39587] " burnus at gcc dot gnu dot org
2009-04-11 15:46 ` jvdelisle at gcc dot gnu dot org
2009-04-14  8:09 ` burnus at gcc dot gnu dot org
2009-04-15  2:17 ` jvdelisle at gcc dot gnu dot org
2009-04-27 11:59 ` burnus at gcc dot gnu dot org
2009-04-27 17:34 ` burnus at gcc dot gnu dot org
2009-04-29  3:38 ` jvdelisle at gcc dot gnu dot org
2009-04-29  4:06 ` jvdelisle at gcc dot gnu dot org
2009-12-05  6:37 ` jvdelisle 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).