skip to Main Content

I integrate cppcheck analysis with CMake by specifying this command line:

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_CPPCHECK="cppcheck;--enable=all;--suppress=missingIncludeSystem;--inline-suppr;--std=c++17;--error-exitcode=1"

and works well.

After upgrading my Ubuntu, with cppcheck version 2.13.0, I started seeing this extra message/warning:

...
[89/108] Building CXX object include/boost/multi/adaptors/fftw/test/CMakeFiles/combinations.cpp.x.dir/combinations.cpp.o
Checking /home/user/boost-multi/include/boost/multi/adaptors/fftw/test/combinations.cpp ...
nofile:0:0: information: Active checkers: 4/592 (use --checkers-report=<filename> to see details) [checkersReport]
...

For every target!

What is the meaning of this message "Active checkers: 4/592"? Why 4?

The help says,

$ cppcheck --help
...
    --checkers-report=<file>
                         Write a report of all the active checkers to the given file.
...

But it doesn’t help me understand.

When I add the option --checkers-report=cppcheck.report, I get the following file

$ cat ./.build.g++.plus/cppcheck.report
Critical errors
---------------
No critical errors, all files were checked.
Important: Analysis is still not guaranteed to be 'complete' it is possible there are false negatives.


Open source checkers
--------------------
No   Check64BitPortability::pointerassignment                  require:portability
No   CheckAssert::assertWithSideEffects                        require:warning
No   CheckAutoVariables::assignFunctionArg                     require:style,warning
No   CheckAutoVariables::autoVariables
No   CheckAutoVariables::checkVarLifetime
No   CheckBool::checkAssignBoolToFloat                         require:style,c++
No   CheckBool::checkAssignBoolToPointer
No   CheckBool::checkBitwiseOnBoolean                          require:style,inconclusive
No   CheckBool::checkComparisonOfBoolExpressionWithInt         require:warning
No   CheckBool::checkComparisonOfBoolWithBool                  require:style,c++
No   CheckBool::checkComparisonOfBoolWithInt                   require:warning,c++
No   CheckBool::checkComparisonOfFuncReturningBool             require:style,c++
No   CheckBool::checkIncrementBoolean                          require:style
No   CheckBool::pointerArithBool
No   CheckBool::returnValueOfFunctionReturningBool             require:style
No   CheckBoost::checkBoostForeachModification
Yes  CheckBufferOverrun::analyseWholeProgram
No   CheckBufferOverrun::argumentSize                          require:warning
No   CheckBufferOverrun::arrayIndex
No   CheckBufferOverrun::arrayIndexThenCheck
No   CheckBufferOverrun::bufferOverflow
No   CheckBufferOverrun::negativeArraySize
No   CheckBufferOverrun::objectIndex
No   CheckBufferOverrun::pointerArithmetic                     require:portability
No   CheckBufferOverrun::stringNotZeroTerminated               require:warning,inconclusive
Yes  CheckClass::analyseWholeProgram
No   CheckClass::checkConst                                    require:style,inconclusive
No   CheckClass::checkConstructors                             require:style,warning
No   CheckClass::checkCopyConstructors                         require:warning
No   CheckClass::checkDuplInheritedMembers                     require:warning
No   CheckClass::checkExplicitConstructors                     require:style
No   CheckClass::checkMemset
No   CheckClass::checkMissingOverride                          require:style,c++03
No   CheckClass::checkSelfInitialization
No   CheckClass::checkThisUseAfterFree                         require:warning
No   CheckClass::checkUnsafeClassRefMember                     require:warning,safeChecks
No   CheckClass::checkUselessOverride                          require:style
No   CheckClass::checkVirtualFunctionCallInConstructor         require:warning
No   CheckClass::initializationListUsage                       require:performance
No   CheckClass::initializerListOrder                          require:style,inconclusive
No   CheckClass::operatorEqRetRefThis                          require:style
No   CheckClass::operatorEqToSelf                              require:warning
No   CheckClass::privateFunctions                              require:style
No   CheckClass::thisSubtraction                               require:warning
No   CheckClass::virtualDestructor
No   CheckCondition::alwaysTrueFalse                           require:style
No   CheckCondition::assignIf                                  require:style
No   CheckCondition::checkAssignmentInCondition                require:style
No   CheckCondition::checkBadBitmaskCheck                      require:style
No   CheckCondition::checkCompareValueOutOfTypeRange           require:style,platform
No   CheckCondition::checkDuplicateConditionalAssign           require:style
No   CheckCondition::checkIncorrectLogicOperator               require:style,warning
No   CheckCondition::checkInvalidTestForOverflow               require:warning
No   CheckCondition::checkModuloAlwaysTrueFalse                require:warning
No   CheckCondition::checkPointerAdditionResultNotNull         require:warning
No   CheckCondition::clarifyCondition                          require:style
No   CheckCondition::comparison                                require:style
No   CheckCondition::duplicateCondition                        require:style
No   CheckCondition::multiCondition                            require:style
No   CheckCondition::multiCondition2                           require:warning
No   CheckExceptionSafety::checkCatchExceptionByValue          require:style
No   CheckExceptionSafety::checkRethrowCopy                    require:style
No   CheckExceptionSafety::deallocThrow                        require:warning
No   CheckExceptionSafety::destructors                         require:warning
No   CheckExceptionSafety::nothrowThrows
No   CheckExceptionSafety::rethrowNoCurrentException
No   CheckExceptionSafety::unhandledExceptionSpecification     require:style,inconclusive
No   CheckFunctions::checkIgnoredReturnValue                   require:style,warning
No   CheckFunctions::checkMathFunctions                        require:style,warning,c99,c++11
No   CheckFunctions::checkMissingReturn
No   CheckFunctions::checkProhibitedFunctions
No   CheckFunctions::invalidFunctionUsage
No   CheckFunctions::memsetInvalid2ndParam                     require:warning,portability
No   CheckFunctions::memsetZeroBytes                           require:warning
No   CheckFunctions::returnLocalStdMove                        require:performance,c++11
No   CheckFunctions::useStandardLibrary                        require:style
No   CheckIO::checkCoutCerrMisusage                            require:c
No   CheckIO::checkFileUsage
No   CheckIO::checkWrongPrintfScanfArguments
No   CheckLeakAutoVar::check                                   require:notclang
No   CheckMemoryLeakInClass::check
No   CheckMemoryLeakInFunction::checkReallocUsage
No   CheckMemoryLeakNoVar::check
No   CheckMemoryLeakStructMember::check
Yes  CheckNullPointer::analyseWholeProgram
No   CheckNullPointer::arithmetic
No   CheckNullPointer::nullConstantDereference
No   CheckNullPointer::nullPointer
No   CheckOther::checkAccessOfMovedVariable                    require:c++11,warning
No   CheckOther::checkCastIntToCharAndBack                     require:warning
No   CheckOther::checkCharVariable                             require:warning,portability
No   CheckOther::checkComparePointers
No   CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse    require:warning
No   CheckOther::checkConstPointer                             require:style
No   CheckOther::checkDuplicateBranch                          require:style,inconclusive
No   CheckOther::checkDuplicateExpression                      require:style,warning
No   CheckOther::checkEvaluationOrder                          require:C/C++03
No   CheckOther::checkFuncArgNamesDifferent                    require:style,warning,inconclusive
No   CheckOther::checkIncompleteArrayFill                      require:warning,portability,inconclusive
No   CheckOther::checkIncompleteStatement                      require:warning
No   CheckOther::checkInterlockedDecrement                     require:windows-platform
No   CheckOther::checkInvalidFree
No   CheckOther::checkKnownArgument                            require:style
No   CheckOther::checkKnownPointerToBool                       require:style
No   CheckOther::checkMisusedScopedObject                      require:style,c++
No   CheckOther::checkModuloOfOne                              require:style
No   CheckOther::checkNanInArithmeticExpression                require:style
No   CheckOther::checkNegativeBitwiseShift
No   CheckOther::checkOverlappingWrite
No   CheckOther::checkPassByReference                          require:performance,c++
No   CheckOther::checkRedundantAssignment                      require:style
No   CheckOther::checkRedundantCopy                            require:c++,performance,inconclusive
No   CheckOther::checkRedundantPointerOp                       require:style
No   CheckOther::checkShadowVariables                          require:style
No   CheckOther::checkSignOfUnsignedVariable                   require:style
No   CheckOther::checkSuspiciousCaseInSwitch                   require:warning,inconclusive
No   CheckOther::checkSuspiciousSemicolon                      require:warning,inconclusive
No   CheckOther::checkUnreachableCode                          require:style
No   CheckOther::checkUnusedLabel                              require:style,warning
No   CheckOther::checkVarFuncNullUB                            require:portability
No   CheckOther::checkVariableScope                            require:style,notclang
No   CheckOther::checkZeroDivision
No   CheckOther::clarifyCalculation                            require:style
No   CheckOther::clarifyStatement                              require:warning
No   CheckOther::invalidPointerCast                            require:portability
No   CheckOther::redundantBitwiseOperationInSwitch             require:warning
No   CheckOther::warningOldStylePointerCast                    require:style,c++
No   CheckPostfixOperator::postfixOperator                     require:performance
No   CheckSizeof::checkSizeofForArrayParameter                 require:warning
No   CheckSizeof::checkSizeofForNumericParameter               require:warning
No   CheckSizeof::checkSizeofForPointerSize                    require:warning
No   CheckSizeof::sizeofCalculation                            require:warning
No   CheckSizeof::sizeofFunction                               require:warning
No   CheckSizeof::sizeofVoid                                   require:portability
No   CheckSizeof::sizeofsizeof                                 require:warning
No   CheckSizeof::suspiciousSizeofCalculation                  require:warning,inconclusive
No   CheckStl::checkDereferenceInvalidIterator                 require:warning
No   CheckStl::checkDereferenceInvalidIterator2
No   CheckStl::checkFindInsert                                 require:performance
No   CheckStl::checkMutexes                                    require:warning
No   CheckStl::erase
No   CheckStl::if_find                                         require:warning,performance
No   CheckStl::invalidContainer
No   CheckStl::iterators
No   CheckStl::knownEmptyContainer                             require:style
No   CheckStl::misMatchingContainerIterator
No   CheckStl::misMatchingContainers
No   CheckStl::missingComparison                               require:warning
No   CheckStl::negativeIndex
No   CheckStl::outOfBounds
No   CheckStl::outOfBoundsIndexExpression
No   CheckStl::redundantCondition                              require:style
No   CheckStl::size                                            require:performance,c++03
No   CheckStl::stlBoundaries
No   CheckStl::stlOutOfBounds
No   CheckStl::string_c_str
No   CheckStl::useStlAlgorithm                                 require:style
No   CheckStl::uselessCalls                                    require:performance,warning
No   CheckString::checkAlwaysTrueOrFalseStringCompare          require:warning
No   CheckString::checkIncorrectStringCompare                  require:warning
No   CheckString::checkSuspiciousStringCompare                 require:warning
No   CheckString::overlappingStrcmp                            require:warning
No   CheckString::sprintfOverlappingData
No   CheckString::strPlusChar
No   CheckString::stringLiteralWrite
No   CheckType::checkFloatToIntegerOverflow
No   CheckType::checkIntegerOverflow                           require:platform
No   CheckType::checkLongCast                                  require:style
No   CheckType::checkSignConversion                            require:warning
No   CheckType::checkTooBigBitwiseShift                        require:platform
No   CheckUninitVar::check
No   CheckUninitVar::valueFlowUninit
Yes  CheckUnusedFunctions::analyseWholeProgram
No   CheckUnusedVar::checkFunctionVariableUsage                require:style
No   CheckUnusedVar::checkStructMemberUsage                    require:style
No   CheckVaarg::va_list_usage                                 require:notclang
No   CheckVaarg::va_start_argument


Premium checkers
----------------
Not available, Cppcheck Premium is not used


Autosar
-------
Not available, Cppcheck Premium is not used


Cert C
------
Not available, Cppcheck Premium is not used


Cert C++
--------
Not available, Cppcheck Premium is not used


Misra C
-------
Misra is not enabled


Misra C++ 2008
--------------
Not available, Cppcheck Premium is not used

2

Answers


  1. I am not an expert on Cppcheck, but I do use it regularly.

    My Understanding of The Problem

    Your report file cppcheck.report suggests certain checks were not enabled with the --enable= flag. For example, you have a lot of require:style or require:warning checkers that you did not enable, like this one here No CheckStl::checkMutexes require:warning.

    What The Cppcheck Source Code Suggests

    From looking at the source code at https://cppcheck.sourceforge.io/devinfo/doxyoutput/cppcheckexecutor_8cpp_source.html on line 344 is the message that gets printed out in this situation. The function creates the list of checkers you enable and generates a report.

    The Reason (Based on my opinion)

    Now, some of the issues are related to the premium version (e.g. checkers for MIRSA, Cert C & C++), so I guess it’s their way to push the premium version of cppcheck. At the same time, there are checks like inconclusive, which at least on my side causes my C++ compiler to complain about specific situations related to my code. The man pages for cppcheck also suggest that the –inconclusive flag can cause false positives. Therefore, I believe that this error is there to make us aware of all the features we are not using in cppcheck and that we as users need to verify whether or not we need those features.

    How To Remove The Error

    One way to remove the error is to add checkersReport to the --suppress= flag so that it can be suppressed. I would advise you to keep the report file though so that you can manually scan it to ensure that all the checkers you wanted to use, have been used.

    Login or Signup to reply.
  2. I added this output to Cppcheck as a part of the safety certification. It makes it visible for users if the expected checkers are executed or not.

    In your case I am not sure why it only says that 4 checkers was executed that sounds very low. There could be some problem.

    I am not sure how cmake executes cppcheck. But is there a "cppcheck build dir" that means the checkers are not executed? That would be fine.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search