[Bug tree-optimization/58143] [4.8/4.9 regression] wrong code at -O3

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Tue Oct 15 13:38:00 GMT 2013


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

--- Comment #27 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to rguenther@suse.de from comment #25)
> > 
> > Why should a undefined value that is not used for anything
> > create such a problem?
> 
> Because undefined behavior includes random effects (like
> formatting your hard drive).  In this case the undefined
> behavior is simply assuming we never reach loop iteration #4
> and thus the loop exit test is never true.
> 
> Richard.

I would have understood that in this example:

   int x[5];
   for (b = 4; b > -30; b--)
     {
     e = x[b];
     for (; c;)
       for (;;)
         {
           if (d)
             break;
         }
     }
   return 0;

bacause x[-1] may trap.

But e = 2147483647 - b;
is just guaranteed to write an undefined
value in e. We have -fno-trapv, or am I wrong?



More information about the Gcc-bugs mailing list