[Bug fortran/53029] missed optimization in internal read (without implied-do-loop)

jvdelisle at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun May 28 23:12:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53029

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I don't remember seeing this bug before. (not saying I had not) 

This patch may fix it. Regression testing. The function
list_formatted_read_scalar is called in the big loop over the array. That loop
only exits if we return and error from here, which we never did. With this
patch the test completes in .007 seconds.

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 6c00d11b..b6cd6670 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -2298,11 +2298,16 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt
type, void *p,
     free_saved (dtp);

 cleanup:
+  /* err may have been set above from finish_separator, so if it is set
+     trigger the hit_eof. The hit_eof will set bits in common.flags.  */
   if (err == LIBERROR_END)
     {
       free_line (dtp);
       hit_eof (dtp);
     }
+  /* Now we check common.flags for any errors that could have occurred in
+     a READ elsewhere such as in read_integer.  */
+  err = dtp->common.flags & IOPARM_LIBRETURN_MASK;
   fbuf_flush_list (dtp->u.p.current_unit, LIST_READING);
   return err;
 }


More information about the Gcc-bugs mailing list