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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |jvdelisle at gcc dot gnu.org
            Summary|Incorrect iostat while      |Bogus END-of-line error
                   |reading SEQUENTIAL file     |with list-directed I/O of
                   |                            |file without trailing
                   |                            |sequential record marker
      Known to fail|                            |4.1.0, 4.9.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Reduced test case - fails with:
  Fortran runtime error: End of file

integer :: i
open(99, access='stream', form='unformatted')
write(99) "5 a"
close(99)

open(99, access='sequential', form='formatted')
read(99, *) i
end


The following happens. finish_list_read has:

  if (dtp->u.p.at_eol)
    {
      dtp->u.p.at_eol = 0;
      return;
    }

  err = eat_line (dtp);
  if (err == LIBERROR_END)
    hit_eof (dtp);

where eat_line has:

  do
    c = next_char (dtp);
  while (c != EOF && c != '\n');
  if (c == EOF)
    return LIBERROR_END;
  return 0;

and next_char ends with:

  dtp->u.p.at_eol = (c == '\n' || c == EOF);
  return c;

And hit_eof has:
        generate_error (&dtp->common, LIBERROR_END, NULL);

Reply via email to