Menu

Value tracking on unisigned variables causes spurious style warnings

Mike
2024-04-19
2024-04-19
  • Mike

    Mike - 2024-04-19

    I am developing some C code on a Raspberry Pi for an embedded system and using cppcheck to help with static analysis. I am using the command line, open source cppcheck version 2.13.
    See attached bar.c.
    When I run "cppcheck --platform=unspecified --enable=all bar.c", I receive a style warning about an always false condition being tested. I think that this warning is a false positive.

     
  • CHR

    CHR - 2024-04-19

    I think this is related to https://trac.cppcheck.net/ticket/10616

     
    • Mike

      Mike - 2024-04-19

      Yes, I agree. Should it be marked as a duplicate? I am not sure I understand kidkat's comment on https://trac.cppcheck.net/ticket/10616 that if we assume overflow is possible, we get other false positives. Might it be possible to evaluate the expression in the conditions to see if is trying to detect overflow?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.