This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/33498] [4.2/4.3 Regression] Optimizer (-O2) may convert a normal loop to infinite



------- Comment #8 from rakdver at gcc dot gnu dot org  2007-09-19 16:56 -------
t #2)
> Technically the testcase invokes undefined behavior because 'val' overflows
> during loop execution.  Practically from a QOI point of view the undefinedness
> should not propagate to the loop exit test (though GCCs behavior is certainly
> standard conforming here).  A nice example for what undefined behavior can
> cause though ;)
> 
> So, not sure if invalid or not.

What happens is that ivopts decide to use val as the variable to use in the
exit compare; they compute what its final value will be (67305984), and replace
the exit test by val != 67305984.

There is not much I can do with that in ivopts.  I could make ivopts avoid
preserving signed variables appearing in the source code that provably
overflow; but I do not think we want to introduce this kind of hacks to handle
code with undefined behavior.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]