This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gfortran patch for PR 18778 Abort on endfile on unopened unit


On Mon, 2004-12-27 at 08:36, Paul Brook wrote:
> > 2004-12-23  Bud Davis  <bdavis9659@comcast.net>
> >
> >  PR fortran/18778
> >  * io/transfer.c (us_read): no bytes available is not a
> >         runtime error.
> >  * io/endfile.c (st_endfile): open the unit if needed.
> 
> > Index: gcc/libgfortran/io/endfile.c
> > ===================================================================
> > !        /* endfile without an open on this unit.
> > !           not an error, so let's make a unit
> > !        */
> > !        memset (&u_flags, '\0', sizeof (u_flags));
> > !        u_flags.access = ACCESS_SEQUENTIAL;
> > !        u_flags.action = ACTION_READWRITE;
> > !        u_flags.form = FORM_UNFORMATTED;
> 
> Why not *_UNSPECIFIED here?
> 
> Other than that, Ok.
> 
> Paul


upon closer reflection, endfile on an un-opened unit is ignored just
fine.... { note to self, find the problem before you fix it :) }


the patch below fixes the problem:

RCS file: /cvs/gcc/gcc/libgfortran/io/transfer.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 transfer.c
*** gcc/libgfortran/io/transfer.c	24 Dec 2004 00:29:07 -0000	1.23
--- gcc/libgfortran/io/transfer.c	24 Dec 2004 03:23:05 -0000
*************** us_read (void)
*** 834,839 ****
--- 834,842 ----
    n = sizeof (gfc_offset);
    p = salloc_r (current_unit->s, &n);
  
+   if (n == 0)
+     return;  /* end of file */
+ 
    if (p == NULL || n != sizeof (gfc_offset))
      {
        generate_error (ERROR_BAD_US, NULL);




changelog same, testsuite file same, results same.




--bud





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]