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
What is the expected behavior?
(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