[Bug tree-optimization/58143] [4.8/4.9 regression] wrong code at -O3
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Tue Oct 15 13:27:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143
--- Comment #25 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 15 Oct 2013, bernd.edlinger at hotmail dot de wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143
>
> --- Comment #24 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
> Wall,
>
> the logic behind the loop niter is really strange
> and the results are simply insane.
>
> When you consider this example:
>
> int a, b, c, d, e;
>
> int
> main ()
> {
> for (b = 4; b > -30; b--)
> {
> e = 2147483647 - b;
> for (; c;)
> for (;;)
> {
> if (d)
> break;
> }
> }
> return 0;
> }
>
> then the reasoning is that an "undefined" value will
> be written to e in loop iteration #4.
> And therefore it does not matter what happens afterwards.
> But for the result of main() which will ultimately be 0
> the undefined value of e does not matter.
>
> 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.
More information about the Gcc-bugs
mailing list