Menu

Operator Equivalence Error : this one is a false positive ?

cgilles
2018-09-25
2018-10-10
  • cgilles

    cgilles - 2018-09-25

    Hi all,

    In the digiKam.org project we use cppcheck reguliary to review codes from students.

    We kill a lots of errors with cppcheck. So in first, thanks to create this wonderfull tool...

    After to cleanup plenty of cppcheck reports, it still few one and especially this one where i'm not sure if it's a false positive or not :

    https://www.digikam.org/reports/cppcheck/master/1.html#line-195

    As assign() operator is called in this equality operator, typically the error about 'd' is not valid. I'm right ?

    Thanks in advance

     
  • versat

    versat - 2018-09-26

    The link does not work any longer, seems they are only temporarily valid.
    I guess at the moment the correct link is https://www.digikam.org/reports/cppcheck/master/2.html#line-195

    I would tend to say it is a false positive, but i hope someone with more knowledge can answer it better.

    I saw that you fixed many things Cppcheck complained about. I am curious what your experience with Cppcheck is. What could be better, what is useful, ...?

     
  • cgilles

    cgilles - 2018-09-28

    digiKam in around 1.5M of C++ lines of code, based on Qt5 API.

    cppcheck report well all problems with badly formated C++ or the real bugs. I can said that 90% of the reports are suitable.

    We voluntary disable style reports and other few one, as you can see in my bash script used in CI :

    https://cgit.kde.org/digikam.git/tree/project/reports/cppcheck.sh

    The CI integration include 2 other static analyzer : scan-build and krazy. All share a same configuration to drop reports from unwanted 3rd party code included in digiKam core and that we don't maintain in time.

    So typically 80% of digiKam code is parsed by static analyzers at end.

    And i can said that cppcheck is really powerfull and help a lots to discover real problem.

    For the false positive, we use inline comment to disable reports.

    A wish : to have a way to disable reports for a block of codes, not just one line.

    Cheer.

     
    • versat

      versat - 2018-10-10

      Just wanted to note that you can enable Qt support by adding the option --library=qt. Maybe that fixes some false positive (and introduces other ones ;). The library is far from beeing complete, but there are already many things specified.

      Do you have any idea/preference how to suppress messages on a block level?
      For PC-Lint such suppressions are possible, but the syntax is somewhat complicated.
      I guess it should be less complicated for Cppcheck.
      Maybe something like
      // cppcheck-suppress-block unusedVariable
      right before the block would be helpful.

       

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.