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

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
Is there a simpler case which is worth addressing, where a condition
is a simple opposite of a predecessor ?

Something like:

void f2( int a, int b)
{
        if (a < b)
                g( a);
        else if (a >= b)
                g( b);
        else
                g( a + b);
}

Static analyser cppcheck can find this:

feb23b.cc:20:13: style: Expression is always true because 'else if' condition
is
 opposite to previous condition at line 18. [multiCondition]
 else if (a >= b)
            ^
feb23b.cc:18:8: note: first condition
 if (a < b)
       ^
feb23b.cc:20:13: note: else if condition is opposite to first condition
 else if (a >= b)
            ^

Reply via email to