------- 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