Menu

Warnings when compiling cppcheck 2.4.1

khouri
2021-03-29
2021-03-29
  • khouri

    khouri - 2021-03-29

    On my system, I noticed a a few compiler warnings when compiling cppcheck 2.4.1. I don't think they affect the working of the tool, but I also could not find a thread on this issue yet. I also don't recall whether these were already present in the previous version (regression) or not.

    Compile flags:
    make USE_Z3=yes MATCHCOMPILER=yes CFGDIR=/usr/share/cppcheck FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function"

    Output (truncated to just the files which had warnings):

    [...]
    g++ -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 -DUSE_Z3 -DFILESDIR=\"/usr/share/cppcheck\" -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -std=c++0x -DHAVE_RULES -DTIXML_USE_STL   -c -o build/valueflow.o build/valueflow.cpp
    build/valueflow.cpp:1837:10: warning: multi-character character constant [-Wmultichar]
         case '<<':
              ^~~~
    build/valueflow.cpp:1839:10: warning: multi-character character constant [-Wmultichar]
         case '>>':
              ^~~~
    build/valueflow.cpp:1841:10: warning: multi-character character constant [-Wmultichar]
         case '&&':
              ^~~~
    build/valueflow.cpp:1843:10: warning: multi-character character constant [-Wmultichar]
         case '||':
              ^~~~
    build/valueflow.cpp:1845:10: warning: multi-character character constant [-Wmultichar]
         case '==':
              ^~~~
    build/valueflow.cpp:1847:10: warning: multi-character character constant [-Wmultichar]
         case '!=':
              ^~~~
    build/valueflow.cpp:1849:10: warning: multi-character character constant [-Wmultichar]
         case '>=':
              ^~~~
    build/valueflow.cpp:1851:10: warning: multi-character character constant [-Wmultichar]
         case '<=':
              ^~~~
    
    [...]
    
    g++ -Ilib -isystem externals/simplecpp -isystem externals/tinyxml2 -DUSE_Z3 -DFILESDIR=\"/usr/share/cppcheck\" -O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function -std=c++0x -DHAVE_RULES -DTIXML_USE_STL   -c -o cli/filelister.o cli/filelister.cpp
    cli/filelister.cpp: In function ‘void addFiles2(std::map<std::__cxx11::basic_string<char>, long unsigned int>&, const string&, const std::set<std::__cxx11::basic_string<char> >&, bool, const PathMatch&)’:
    cli/filelister.cpp:213:73: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations]
                 while ((readdir_r(dir, &dir_result_buffer.entry, &dir_result) == 0) && (dir_result != nullptr)) {
                                                                             ^
    In file included from cli/filelister.cpp:176:0:
    /usr/include/dirent.h:183:12: note: declared here
     extern int readdir_r (DIR *__restrict __dirp,
                ^~~~~~~~~
    

    Platform:
    Ubuntu 18.04.5 LTS

    Versions of relevant packages:

    $ apt-show-versions sudo gcc libpcre3-dev libz3-dev xsltproc docbook-xsl docbook-xml
    docbook-xml:all/bionic 4.5-8 uptodate
    docbook-xsl:all/bionic 1.79.1+dfsg-2 uptodate
    gcc:amd64/bionic-security 4:7.4.0-1ubuntu2.3 uptodate
    libpcre3-dev:amd64/bionic 2:8.39-9 uptodate
    libz3-dev:amd64/bionic 4.4.1-0.3build4 uptodate
    sudo:amd64/bionic-security 1.8.21p2-3ubuntu1.4 uptodate
    xsltproc:amd64/bionic-security 1.1.29-5ubuntu0.2 uptodate
    
     
  • Daniel Marjamäki

    thanks!

    In most cases multichar constants are probably mistakes but in these cases we use those intentionally. So it would be good to hide these warnings somehow.

    That deprecated warning has been written for a long time. When it first appeared many years ago we did not want to change because we did not want to break old tool chains.. well it feels like that was a long time ago so I think it could be considered. If you fix it then what glibc version etc would be required?

     
  • khouri

    khouri - 2021-03-29

    I don't know what the minimum glibc version needed would be. My current setup has the following installed for glib:

    $ apt list --installed | grep glib
    gir1.2-glib-2.0/bionic,now 1.56.1-1 amd64 [installed,automatic]
    libdbus-glib-1-2/bionic,now 0.110-2 amd64 [installed,automatic]
    libglib2.0-0/bionic-updates,bionic-security,now 2.56.4-0ubuntu0.18.04.8 amd64 [installed,automatic]
    libglib2.0-bin/bionic-updates,bionic-security,now 2.56.4-0ubuntu0.18.04.8 amd64 [installed,automatic]
    libglib2.0-data/bionic-updates,bionic-security,now 2.56.4-0ubuntu0.18.04.8 all [installed,automatic]
    libglib2.0-dev/bionic-updates,bionic-security,now 2.56.4-0ubuntu0.18.04.8 amd64 [installed,automatic]
    libglib2.0-dev-bin/bionic-updates,bionic-security,now 2.56.4-0ubuntu0.18.04.8 amd64 [installed,automatic]
    

    However, glib versions which are quite a bit older will surely also work if this warning has been around for a while.

     

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.