https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83649
Bug ID: 83649 Summary: Large reads fail Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: jb at gcc dot gnu.org Target Milestone: --- Consider the testcase program largewr integer(kind=1) :: a(2_8**31+1) a = 0 a(size(a, kind=8)) = 1 open(10, file="largewr.dat", access="stream", form="unformatted") write (10) a close(10) a(size(a, kind=8)) = 2 open(10, file="largewr.dat", access="stream", form="unformatted") read (10) a if (a(size(a, kind=8)) == 1) then print *, "All is well" else print *, "Oh no" end if end program largewr This fails on x86_64-pc-linux-gnu with ./a.out At line 10 of file largewr.f90 (unit = 10, file = 'largewr.dat') Fortran runtime error: End of file [snip] The reason is that Linux never reads or writes more than 2,147,479,552 bytes in a single syscall. For write libgfortran does the writing in a loop, and it's handled correctly, but for read we cannot do that loop since then it will hang when reading from the terminal where short reads are perfectly Ok.