------- Comment #1 from burnus at gcc dot gnu dot org  2010-03-05 09:07 -------
Jerry, can you have a look?

With gfortran 4.1 and 4.2, g95, ifort, openf95, and NAG f95 the program
immediately returns with "ended". However, in gfortran 4.3, 4.4, and 4.5 it
simply loops through without hitting "end=".

Using *  instead of  (x)  as fmt, I get immediately an "End of File" - as
expected. (In my case, there was no file and OPEN created an empty one.)


In a way it is not surprising. In io/read.c:

  read_x (st_parameter_dt * dtp, int n)
    [...]
      read_sf (dtp, &n, 1);

and then in io/transfer.c:

  read_sf (st_parameter_dt *dtp, int * length, int no_error)
    [...]
    /* If we hit EOF previously with the no_error flag set (i.e. X, T,
       TR edit descriptors), and we now try to read again, this time
       without setting no_error.  */
    if (!no_error && dtp->u.p.at_eof)
      {
        *length = 0;
        hit_eof (dtp);
        return NULL;
      }
    [...]
    base = p = fbuf_read (dtp->u.p.current_unit, length);
    if (base == NULL)
      return NULL;


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|i686-pc-linux-gnu           |
           Keywords|                            |wrong-code
      Known to fail|                            |4.3.4 4.4.4 4.5.0
      Known to work|                            |4.1.2 4.2.1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-05 09:07:49
               date|                            |
            Summary|Read no longer jumps on end |[4.3/4.4/4.5 Regression] No
                   |                            |EOF condition if reading
                   |                            |with '(x)' from an empty
                   |                            |file
   Target Milestone|---                         |4.4.4


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

Reply via email to