[Bug middle-end/57904] [4.9 Regression] Bogus(?) "invokes undefined behavior" warning with Fortran's finalization wrapper (gfortran.dg/class_48.f90)

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Fri Dec 20 05:51:00 GMT 2013


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

--- Comment #9 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 31485
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31485&action=edit
change code generation for simple DO-loops

This not yet fully tested patch changes the DO-loop code generation
to a more loop-niter frendly way.

before:
   if ((step > 0) ? (dovar <= to) : (dovar => to))
    {
      for (;;)
        {
          body;
   cycle_label:
          cond = (dovar == to);
          dovar += step;
          if (cond) goto end_label;
        }
      }
   end_label:


after:
   if ((step > 0) ? (dovar <= to) : (dovar => to))
    {
      for (;;)
        {
          body;
   cycle_label:
          cond = (step > 0) ? (dovar >= to) : (dovar <= to);
          dovar += step;
          if (cond) goto end_label;
        }
      }
   end_label:

this is more easy to see, that dovar can not overflow:
what do you think of it?



More information about the Gcc-bugs mailing list