https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92210

--- Comment #5 from David Binderman <dcb314 at hotmail dot com> ---
Not only does clang detect that the control variable isn't changed,
it also detects when the control variable is changed too much.

Code like this gets warned:

for (int i = 0; i < 10; ++i)
{
 // whatever
 ++i;
}

aug29c.cc:9:5: warning: variable 'i' is incremented both in the loop header and
in the loop body [-Wfor-loop-analysis]
                ++i;
                  ^
aug29c.cc:6:28: note: incremented here
        for (int i = 0; i < 10; ++i)
                                  ^

Reply via email to