[Bug c/104680] identical inner condition not detected

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 3 14:26:04 GMT 2022


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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|analyzer                    |c
           Assignee|dmalcolm at gcc dot gnu.org        |unassigned at gcc dot gnu.org

--- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
There are two aspects to this bug:

(a) the code flagged by cppcheck's implementation of "identicalInnerCondition"
warnings from cppcheck when run on GCC itself.  I've posted comments above
giving some details on each of these.

(b) the fact that GCC's -Wduplicated-branches doesn't flag these issues, when
arguably it should (though note the possible false positives above).


Re (a), should these be opened as bugs against individual subsystems?

Re (b) and in reply to Andrew Pinski from comment #1):
> Wduplicated-branches only currently works for the a && a case and not the if
> (a) if (a) case.
> 
> Maybe this could be done by the analyzer instead.

...I don't think this is a good fit for the analyzer; it seems much more
appropriate for the frontends to me; reassigning component to "c".

Hope this is constructive.


More information about the Gcc-bugs mailing list