Menu

clang18 and -Weverything

2023-12-23
2024-01-19
  • Andrew C Aitchison

    When building the current git head with clang18 I get 70+ warnings like:
    clang++-18 -DFILESDIR=\"/usr/local/share/Cppcheck\" -DHAVE_RULES -I/home/werdna/git/cppcheck/build/externals/simplecpp -I/home/werdna/git/cppcheck/externals/simplecpp -g -std=gnu++11 -Weverything -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -Woverloaded-virtual -gdwarf-4 -Wno-documentation-unknown-command -Wno-unused-exception-parameter -Wno-old-style-cast -Wno-sign-conversion -Wno-shadow-field-in-constructor -Wno-covered-switch-default -Wno-shorten-64-to-32 -Wno-implicit-int-conversion -Wno-double-promotion -Wno-shadow-field -Wno-shadow-uncaptured-local -Wno-implicit-float-conversion -Wno-switch-enum -Wno-float-conversion -Wno-enum-enum-conversion -Wno-date-time -Wno-disabled-macro-expansion -Wno-bitwise-instead-of-logical -Wno-unsafe-buffer-usage -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-four-char-constants -Wno-weak-vtables -U_GLIBCXX_DEBUG -Wno-zero-as-null-pointer-constant -MD -MT externals/simplecpp/CMakeFiles/simplecpp_objs.dir/simplecpp.cpp.o -MF CMakeFiles/simplecpp_objs.dir/simplecpp.cpp.o.d -o CMakeFiles/simplecpp_objs.dir/simplecpp.cpp.o -c /home/werdna/git/cppcheck/externals/simplecpp/simplecpp.cpp
    /home/werdna/git/cppcheck/externals/simplecpp/simplecpp.cpp:1068:13: warning: 'switch' missing 'default' label [-Wswitch-default]
    1068 | switch (tok->op) {

    By using -Weverything we appear to have turned on Wswitch-default
    There are several styles of defensive coding and lots of switch warning options; I don't know whether you want to turn this one off too with -Wno-switch-default, or add a default for each switch (which might hide a missing value if we ever extend an enum).

     
  • Oliver Stöneberg

    This is a new warning in Clang 18 and we will be ignroing it since it coflicts with -Wswitch-default.

    We usually do not apply changes for upcoming compiler releases ahead of time.

    But we (well, I) keep track of the necessary changes for the next Clang version in a branch/PR - see https://github.com/danmar/cppcheck/pull/5305. In the past we switched compilers and applied the changes around the time the release candidates go out as that should be a good point in time where most the changes affect us should be stable.

     

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.