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

David Binderman <dcb314 at hotmail dot com> changed:

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

--- Comment #12 from David Binderman <dcb314 at hotmail dot com> ---
Interestingly, both gcc and clang have nothing to say about this code:

extern void g( int);

void f( int a)
{
        if (a >= 0)
        {
                if (a < 0)
                {
                        g(a);
                }
        }
}

$ /home/dcb/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -Wunreachable-code
jan20e.cc
$

cppcheck finds the problem:

$ cppcheck --enable=all jan20e.cc
Checking jan20e.cc ...
jan20e.cc:10:9: warning: Opposite inner 'if' condition leads to a dead code
block. [oppositeInnerCondition]
  if (a < 0)
        ^
jan20e.cc:8:8: note: outer condition: a>=0
 if (a >= 0)
       ^

Reply via email to