PVS-Studio is a static code analysis tool for detecting bugs and security weaknesses in the source code of programs, written in C, C++, C# and Java. It analyze source code intended for 32-bit, 64-bit and embedded ARM platforms. Official page can be found here.
PVS-Studio performs a wide range of code checks, and it is also useful in finding misprints and Copy-Paste errors. These checks are static analysis checks that can be performed at a source code level. Some of the defects that might be detected include:
- Arithmetic over/underflow
- Array index out of bounds
- Undefined/unspecified behavior
- Incorrect usage of exceptions
- Buffer overrun
- Null pointer/null reference dereference
- Improper understanding of function/class operation logic
- Illegal bitwise/shift operations
The full list of supported checks can be found on the official webpage.
[env:myenv] platform = ... board = ... check_tool = pvs-studio
Useful options that can be used used for adjusting check process:
Useful flags that can help more precisely configure PVS-Studio to satisfy your project requirements:
Analysis mode (
0- full analysis (default),
1- 64-bit. analysis,
4- general analysis,
16- customer’s specific requests,
Errors activation (Default: all errors is on)
Errors OFF (Default: all errors is on)
All code that is located under the path will be excluded from analysis
Path to custom license file. Default locations
~/.config/PVS-Studio/PVS-Studio.licon Unix and
Specifies the path to rules configuration file.
Platform name (Win32, x64, etc) (Default:
An example with a special analysis mode, disabled errors and license file:
[env:myenv] platform = ... board = ... check_tool = pvs-studio check_flags = pvs-studio: --analysis-mode=4 --errors-off=V532,V586 --lic-file=/path/to/file.lic
Since PVS-Studio is a paid B2B solution, a license should be purchased. But PVS-Studio can be used for free of charge, for example for checking open source projects. More information about the cases when you can get a free PVS-Studio license can be found on the official webpage.
An example with a custom analysis mode disabled errors:
[env:myenv] platform = ... board = ... check_tool = pvs-studio check_flags = pvs-studio: --analysis-mode=4 --errors-off=V532,V586