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

--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Lukasz Dorau from comment #3)
> (In reply to Markus Trippelsdorf from comment #2)
> > When v.hosts[0] or v.hosts[1] is NULL the loop is fine, so there is
> > no reason for a warning.
> > The testcase is obviously invalid.
> >
> But v.hosts[0] and v.hosts[1] do not have to be NULL. What's more, they are
> supposed not to be NULL. So why is it invalid?
> I understand that the loop is erroneous, but I do not understand why
> misoptimizing the code by dropping 'id < 2' loop condition is a right thing
> to do? And even without any warning?

Please note that you can use -fno-aggressive-loop-optimization if you 
dislike this behavior.

From http://gcc.gnu.org/bugs/:
 »if compiling with -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations makes a difference, your code probably is
not correct«

And -Wno-aggressive-loop-optimizations doesn't handle early loop exits.

Reply via email to