To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at

If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

PVS-Studio: Support of MISRA C and MISR…

PVS-Studio: Support of MISRA C and MISRA C++ Coding Standards

Dec 10 2018

Starting with the version 6.27, the PVS-Studio static code analyzer can classify its warnings according to MISRA C and MISRA C++ standards. Due to support of these standards it has become possible to effectively use the analyzer to increase the level of security, portability and reliability of programs for embedded systems.


Update. Our site now has the new section "Classification of PVS-Studio warnings according to the standards: MISRA C, MISRA C++". It provides the mapping table of the PVS-Studio diagnostics and rules described in the MISRA C:2012 and MISRA C++:2008.

This year we took up supporting of such standards, as CWE and SEI CERT in the PVS-Studio analyzer. Basically support itself came down to classifying diagnostics which have already been implemented in the analyzer according to these standards. In addition, to comply better to these standards, several new diagnostics were implemented and the old ones were extended.

Mapping tables of PVS-Studio diagnostics to different standards:

Now time has come for MISRA C and MISRA C++ standards. These are standards of software development in C and C++ languages, created by MISRA (Motor Industry Software Reliability Association). The purpose of the standards is to improve safety, portability and reliability of programs for embedded systems. The text of the standards is chargeable.

We believe, the ability to simply start using our analyzer in an already existing large project is its strong point. You can run PVS-Studio on a code base to detect old errors and then use the analyzer regularly to find new defects as early as possible.

Many analyzers are on a different path and implement diagnostics related to coding standards. They suggest how to name the variables better, remind to paste comments at the beginning of the file, and so on. It is needed and useful. However, in this case analyzers become very noisy and they generate a huge number of warnings, in which bug related warnings can be hardly found.

We decided that PVS-Studio will be the analyzer which is specifically looking for errors. It's a competitive edge of it. A developer can run it on a large code base and be certain that he won't be overwhelmed by the incredible number of warnings on his coding style. Eventually, he'll be able to focus on bugs.

So initially we have been critical to the MISRA standards and haven't planned to introduce them for a long time. MISRA standards are intended to simplify and improve code quality in general, which helps prevent errors. That is, most of their diagnostics refer to the style of writing code. This is best illustrated with an actual example.

MISRA standard includes the rule, according to which bodies of if statements must be enclosed in curly brackets. In MISRA C it is the rule 15.6, while in C++ it is 6-4-1 MISRA. Example of incorrect code:

if (i == bestOffs) continue;

Correct code:

if (i == bestOffs)

Such diagnosis can't be applied to already existing projects developed for Windows, Linux or macOS operating systems. For example, only one rule about curly brackets described above gives 1947 warnings of the V2507 diagnostic (MISRA C 15.6, MISRA C++ 6-4-1) for a WinMerge project. Still WinMerge is a small project! In total, only 250 000 lines of code in C and C# languages.

Until 2018 the PVS-Studio analyzer was focused on checking the desktop applications working under Windows, Linux and macOS. Accordingly, MISRA support had little practical meaning. No one will implement this standard in a large existing desktop project.

Everything changed when in 2018 we've started supporting embedded systems. This year we supported the following features in the analyzer:

  • Windows. IAR Embedded Workbench, C/C++ Compiler for ARM C, C++
  • Windows/Linux. Keil µVision, DS-MDK, ARM Compiler 5/6 C, C++
  • Windows/Linux. Texas Instruments Code Composer Studio, ARM Code Generation Tools C, C++
  • Windows/Linux/macOS. GNU Arm Embedded Toolchain, Arm Embedded GCC compiler, C, C++

Unlike desktop projects, many embedded developers already write projects, taking into account MISRA recommendations and their support in our analyzer will be definitely useful for developers.

Nevertheless, we are still concerned that some developers who hasn't puzzled them out, may think that we have "spoiled" the analyzer by introducing some "strange" diagnostics. Therefore, MISRA diagnostics are disabled by default. We believe this is a right decision. We suggest enabling them only if you understand exactly why they are needed and how to use them.

For example, it can be confusing for application programmers, why suddenly the analyzer forbids them to use dynamic memory. For instance, why all of a sudden you cannot allocate memory using the malloc function or the new operator. Nevertheless, such restrictions (V2511) are well understood by developers of embedded devices. In some devices, working continuously, it is truly unacceptable to use programs which can suddenly run out of memory.

So now you can install or upgrade PVS-Studio and start using diagnostics based on rules from MISRA C and MISRA C++. The set of supported rules is incomplete, but it shouldn't be an obstacle to start using PVS-Studio. At the moment there is no static analyzer which covers absolutely all MISRA rules. In the future we're planning to expand the set of diagnostic rules implemented in MISRA and hope to become a leading tool in fullness of their support.

To enable MISRA diagnostics in Visual Studio or in the PVS-Studio Standalone utility, you need to change Disabled for Show All in settings.


As Disabled means that warnings aren't generated at all and they don't get into a report, you will need to restart the analysis. The Disabled mode is set by default in order to reduce the size of the report. By turning on MISRA diagnostics you might get a huge number of warnings. In addition, report files (*.plog - files) might significantly grow in size.

To analyze projects in Linux and macOS operating systems there is the pvs-studio analyzer utility. By default only general analysis diagnostics are enabled there (General Analysis, GA). To enable additional rules, you can use the option "-a":

-a [MODE], --analysis-mode [MODE]
        MODE defines the type of warnings:
        1 - 64-bit errors;
        2 - reserved;
        4 - General Analysis;
        8 - Micro-optimizations;
        16 - Customers Specific Requests;
        32 - MISRA.
        Modes can be combined by adding the values
        Default: 4

To enable GA and MISRA warnings you need to run the analysis with the following parameters:

pvs-studio-analyzer analyze ... -a 36 ... -o /path/to/report.log ...

36 is a bitwise OR for 4 (GA - General Analysis diagnostic) and 32 (MISRA).

Further, we recommend that you create multiple reports with different types of warnings, as follows:

plog-converter -a GA:1,2 -t tasklist
  -o /path/to/ga_results.tasks /path/to/project.log
plog-converter -a MISRA:1,2,3 -t tasklist -m misra
  -o /path/to/misra_results.tasks /path/to/project.log

The first report "ga_results.tasks" will contain general analysis warnings of High and Medium certainty levels .

The second report "misra_results.tasks" will include only warnings related to MISRA of all levels. The key "-m misra" indicates that the report, in addition to numbers in the PVS-Studio format, will also include diagnostics according to the MISRA classification.

All running modes of the analyzer in Linux and macOS as well as reporting formats are described in the documentation.

P.S. We'd like to assess the extent to which our choice of MISRA as one of directions of PVS-Studio development was correct. If you are interested in this topic, please write to us. Even if you aren't planning to use PVS-Studio, please write anyway. We'd like to ask you a few clarifying questions.

Additional links:

Popular related articles
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
Free PVS-Studio for those who develops open source projects

Date: Dec 22 2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: Oct 22 2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →