public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95476] New: Reading file of length zero
@ 2020-06-02  8:43 m.diehl at mpie dot de
  2020-06-07  8:29 ` [Bug fortran/95476] " tkoenig at gcc dot gnu.org
  2020-06-07 13:29 ` m.diehl at mpie dot de
  0 siblings, 2 replies; 3+ messages in thread
From: m.diehl at mpie dot de @ 2020-06-02  8:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95476

            Bug ID: 95476
           Summary: Reading file of length zero
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.diehl at mpie dot de
  Target Milestone: ---

There is some ambiguity when reading a file of zero length:

program test

 character(len=:), allocatable :: a
 a = IO_read('empty.txt')

 print*, len(a)
 print*, '#'//a//'#'

contains

function IO_read(fileName) result(fileContent)

  character(len=*),  intent(in) :: fileName
  character(len=:), allocatable :: fileContent
  integer ::  &
    fileLength, &
    fileUnit, &
    myStat

  inquire(file = fileName, size=fileLength)
  open(newunit=fileUnit, file=fileName, access='stream',&
       status='old', position='rewind', action='read',iostat=myStat)
  if(myStat /= 0) stop 1
  allocate(character(len=fileLength)::fileContent)
  read(fileUnit,iostat=myStat) fileContent
  print*, mystat
  close(fileUnit)

end function IO_read

end program test

see also the discussion on 
https://software.intel.com/en-us/comment/1960049#comment-1960049

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

* [Bug fortran/95476] Reading file of length zero
  2020-06-02  8:43 [Bug fortran/95476] New: Reading file of length zero m.diehl at mpie dot de
@ 2020-06-07  8:29 ` tkoenig at gcc dot gnu.org
  2020-06-07 13:29 ` m.diehl at mpie dot de
  1 sibling, 0 replies; 3+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2020-06-07  8:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95476

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu.org

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
What is the expected behavior?

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

* [Bug fortran/95476] Reading file of length zero
  2020-06-02  8:43 [Bug fortran/95476] New: Reading file of length zero m.diehl at mpie dot de
  2020-06-07  8:29 ` [Bug fortran/95476] " tkoenig at gcc dot gnu.org
@ 2020-06-07 13:29 ` m.diehl at mpie dot de
  1 sibling, 0 replies; 3+ messages in thread
From: m.diehl at mpie dot de @ 2020-06-07 13:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95476

Martin Diehl <m.diehl at mpie dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Martin Diehl <m.diehl at mpie dot de> ---
(In reply to Thomas Koenig from comment #1)
> What is the expected behavior?

According to the comment by S. Lionel, the behavior of gfortran conforms to the
standard

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

end of thread, other threads:[~2020-06-07 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  8:43 [Bug fortran/95476] New: Reading file of length zero m.diehl at mpie dot de
2020-06-07  8:29 ` [Bug fortran/95476] " tkoenig at gcc dot gnu.org
2020-06-07 13:29 ` m.diehl at mpie dot de

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).