Cppcheck Versions Save

static analysis of C/C++ code

2.5

2 years ago

Parser:

  • various fixes
  • checked that all features in c++11, c++14, c++17 are supported
  • c++20 support is improved but not complete yet

Core:

  • improved library files, better knowledge about APIs
  • improved checks to detect more bugs
  • fixed checks to avoid unwanted warnings

Changed output:

  • try to use relative paths when using compile databases, if compile database is accessed with relative path
  • updated XML; The file0 attribute is moved from to

Misra:

  • fixed crashes and false positives

New checks:

  • suspicious container/iterator assignment in condition
  • rethrow without current handled exception

2.4.1

3 years ago

Fixed windows installer, a file needed by the Misra addon was missing.

2.4

3 years ago

Fixed false negatives and false positives

New check; Detect one definition rule violations

Various improvements:

  • MISRA improvements
  • ImportProject fixes
  • Various bug hunting improvements
  • Fixes when importing AST from clang

2.3

3 years ago

Improved C++ parser:

  • types
  • wrong operands in ast
  • better simplification of templates

Improved clang import, various fixes. Improved value flow analysis

Fixed false positives

Improved configuration in library files

  • boost.cfg
  • googletest.cfg
  • qt.cfg
  • windows.cfg
  • wxwidgets.cfg

Added several Misra rules:

  • 6.1
  • 6.2
  • 7.2
  • 7.4
  • 9.2
  • 10.2
  • 15.4

Added platforms:

  • elbrus e1c+
  • pic
  • pic8
  • mips

2.2

3 years ago

New checks:

  • incorrect usage of mutexes and lock guards
  • Dereference end iterator
  • Iterating a known empty container
  • outOfBounds check for iterators to containers

Removed 'operator=' check that ensures reference to self is returned. That is not about safety.

Improved parser

  • various ast fixes

Clang parser

  • The Clang import feature in Cppcheck should be considered to be experimental for now. There are problems.

Improved bug hunting

  • variable constraints
  • handling of multidimension arrays
  • function calls, execute functions that are in same TU
  • improved handling of containers
  • several improvements for uninitialized variables check
  • improved analysis of for loops
  • added a hash value for warnings that can be used for suppressions

Improved data flow

  • one more heuristic for ternary operators
  • improved data flow for containers

CLI:

  • Fixed some addon execution problems when there are spaces etc

GUI:

  • Fix handling of tags
  • Exclude files

cppcheck-htmlreport:

  • several result files can be combined into 1 output

Suppressions:

  • comments can be added at end of suppression in suppressions file

2.1

3 years ago

This is a minor release.

We have tweaked build scripts.

  • When you use USE_Z3=yes, we will handle new versions of z3 better. If you have an old z3 library and get compilation problems you will need to add a z3_version.h in externals.
  • The cmake scripts was updated.

There was a couple of bug fixes.

New check:

  • for "expression % 1" the result is always 0.

2.0

3 years ago

Overview

The command line is not changed drastically. Your old cppcheck scripts should work as before.

Compiling: There is a new dependency Z3. When compiling with the Makefile it is highly recommended to use "USE_Z3=yes".

Improved clang-tidy integration

Several fixes to;

  • improve parsing
  • detect more bugs with existing checks
  • fix false alarms

Clang import

Clang is a C/C++ compiler that has a very robust and well made parser.

Cppcheck will always use its internal parser by default. However there is now an option to use the Clang parser instead.

It is recommended that you use the default internal Cppcheck parser unless you notice that it fails to parse your code properly (syntax errors, strange false alarms).

Bug hunting

There is a new "soundy" analysis in Cppcheck that should detect most bugs. You should expect false alarms, however the false alarms will not be overwhelming.

This new "soundy" analysis is not intended to replace normal Cppcheck analysis. There are use cases where false alarms can not be tolerated.

We have added 1 checker and that checks for division by zero:

  • It detects all "integer division by zero" bugs in the Juliet test suite.
  • It detects all "division by zero" bugs in the ITC test suite.
  • There was 28 division by zero CVEs published in 2019 for C/C++ open source projects, and we could quickly see that 21 of the bugs are found by Cppcheck. There is no CVE bug that we know Cppcheck fails to diagnose. But there are 7 CVEs that would require additional investigation to establish if it is really detected or not.

You can read more about this analysis in the "Bug hunting" chapter in the manual.

1.90

4 years ago

New check:

  • alias to vector element invalid after vector is changed

Improved checking:

  • improved value flow analysis for struct members
  • improved value flow analysis for pointer alias

CERT:

  • Added ENV33-C: Do not call system()

MISRA:

  • Added rule 2.7
  • Added rule 3.2
  • Added rule 4.2
  • Added rule 14.2
  • Added rule 21.1
  • Added rule 21.12

1.89

4 years ago

Command line:

  • The default warning message format was changed. The new format is similar to GCC. If you want to get warnings in the old format, add --template=cppcheck1 to the command line.

Compiling:

  • From now on, use FILESDIR instead of CFGDIR to specify the path for Cppcheck data files. The readme.txt describes the available flags.

Improved checking:

  • improved value flow analysis for pointer aliases
  • improved checking for uninitialized variables/structs
  • better checking of smart pointers
  • better checking of global variables
  • Added Cppcheck annotations cppcheck_low(VALUE) and cppcheck_high(VALUE)
  • shadow variables; warn when argument is shadowed
  • warn if local reference variable can be const

CERT:

  • Added API01-C: Avoid laying out strings in memory directly before sensitive data
  • Added MSC24-C: Do not use deprecated or obsolescent functions
  • Added STR11-C: Do not specify the bound of a character array initialized with a string literal

MISRA:

  • Added rule 17.2
  • Added rule 18.4
  • Added rule 18.7

GUI:

  • Minor tweaks

1.88

4 years ago

New checks:

  • Comparing pointers that point to different objects
  • Address of local variable 'x' is accessed at non-zero index
  • STL usage: unnecessary search before insertion
  • Duplicate expression for condition and assignment: if (x==3) x=3;

Added --library configuration files for:

  • cppunit
  • libcerror
  • nspr
  • opengl
  • sqlite3

Better handling of C++14 and C++17

Command line:

  • New command line option --addon used to run addons directly from Cppcheck.
  • Some advanced options are only available in GUI:
    • remove unused declarations in header files to speedup analysis
    • remove unused templates to speedup analysis
    • when checking visual studio project, only check 1 configuration
    • max whole-program-analysis call stack depth To get these features in command line tool, create a GUI project file and import that on command line using --project.

GUI:

  • started implementing theme support

Makefile: Please use MATCHCOMPILER=yes instead of SRCDIR=build when compiling to enable the match compiler.

Cert:

  • add check exp15-c
  • add check str03-c
  • add check str05-c
  • add check str07-c

Misra:

  • Add check 17.7
  • Add check 20.7
  • Add check 20.10