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

--- Comment #14 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to David Binderman from comment #12)
> 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)
>        ^

That's bug 82100, which is already linked under "See Also"

Reply via email to