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.

How to quickly check out interesting wa…

How to quickly check out interesting warnings given by the PVS-Studio analyzer for C and C++ code?

Jun 24 2019

Once in a while, programmers who start getting acquainted with the PVS-Studio code analyzer ask me: "Is there a list of warnings that accurately indicate errors?" There is no such list because uninteresting (false) warnings in one project are very important and useful in another one. However, one can definitely start digging into the analyzer from the most exciting warnings. Let's take a closer look at this topic.


Trouble is, as a rule, at first runs a programmer drowns in a huge number of warnings that he gets. Naturally, he wants to start reviewing the most interesting warnings in order to understand whether he should spend his time sorting out all this. Good, so here are three simple steps that will let him check out the most exciting warnings.

Step 1


Disable all types of warnings except general ones (GA). A common mistake is to enable all types of warnings. Inexperienced users think that the more to enable, the better. That's not the case. There are diagnostic sets, such as 64-bit checks and MISRA rules, that should only be used when one clearly knows what are they and how to work with them. For example, enabling MISRA diagnostics for an ordinary application program, you will drown in tens, thousands or hundreds of thousands of warnings such as:

  • V2506. MISRA. A function should have a single point of exit at the end.
  • V2507. MISRA. The body of a loop\conditional statement should be enclosed in braces.
  • V2523. MISRA. All integer constants of unsigned type should have 'u' or 'U' suffix.

Most MISRA warnings indicate not errors, but code smells. Naturally, a programmer begins to ask questions. How do you find something interesting in the pile of all these warnings? What numbers should he watch? These are the wrong questions. You just need to disable the MISRA set. This is the standard for writing quality code for embedded devices. The point of the standard is to make the code extremely simple and understandable. Don't try to apply it where it's inappropriate.

Note. Yes, MISRA has rules designed to identify real bugs. Example: V2538 - The value of uninitialized variable should not be used. But don't be afraid to disable the MISRA standard. You're not going to lose anything. The real errors will still be found as part of the General Diagnostics (GA). For example, an uninitialized variable will be found by the V614 diagnostic.

Step 2


Any static analyzer issues false positives at the first runs and requires some configuring. Nothing can be done about it, but it's not as scary as it may seem. Even a simple quick setting allows you to remove most false positives and start viewing a quite relevant report. I won't talk more about it, as I have written about it many times, for example, in this article: "Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives".

Spend a little time disabling obviously irrelevant warnings and fighting against false positives related to macros. Generally speaking, macros are the main reason of false positives, as a warning appears in all cases when a poorly implemented macro is used. To suppress warnings in macros, you can write comments of a special type next to their declaration. The more of comments format is covered in the documentation.

Yes, the initial setting will take a little time, but will drastically improve the perception of the report by eliminating the distracting noise. Take some time to do it. If there are any difficulties or questions, we are always ready to help and tell you how to set up the analyzer in the best way. Feel free to write and ask us questions.

Step 3


Start viewing warnings from Level 1. Only after it watch 2 and 3. Warning levels are nothing more than the veracity of a warning. Warnings of the Level 1 are more likely to indicate an actual error than warnings of the Level 2.

You can say, when you choose to "watch Level 1," you press the "watch the most interesting errors" button.

In more detail, the classification of PVS-Studio warnings by levels is described in the article "The way static analyzers fight against false positives, and why they do it".

So why isn't there a list?


However, the idea of having a list of the most useful warnings may still seem reasonable. Let me show you in a practical example that the usefulness of a diagnostic is relative and depends on the project.

Let's consider the V550 warning. The warning detects a potential error related to the fact that in order to compare numbers with a floating-point the operators == or != are used.

Most of the developers I've talked to, think that this diagnostic is useless and they disable it because all its triggerings for their project are false. That's why this diagnostic has low level of certainty and relates to the Level 3.

Indeed, in most applications, float/double types are used in very simple algorithms. Often the comparison with the constant is used solely to check if a certain value is set by default, or whether it has changed. In this case, the exact check is quite appropriate. I'll explain it with pseudo-code.

float value = 1.0f;
if (IsUserInputNewValue())
  value = GetUserValue();
if (value == 1.0f)

Here the comparison (value of 1.0f) is correct and safe.

Does this mean that the V550 diagnostic is uninteresting? No. It all depends on the project. Let me quote a snippet from the article "How We Tried Static Analysis on Our X-Ray Endovascular Surgery Training Simulator Project", written by our user.

So, what our static analyzer pays attention to here:

V550 An odd precise comparison: t != 0. It's probably better to use a comparison with defined precision: fabs(A - B) > Epsilon. objectextractpart.cpp 3401

D3DXVECTOR3 N = VectorMultiplication(
VectorMultiplication(V-VP, VN), VN);
float t = Qsqrt(Scalar(N, N));
if (t!=0)
  V = V - N * DistPointToSurface(V, VP, N);

Errors of such type repeat quite often in this library. I can't say it came as a surprise to me. Previously, I've met incorrect handling of numbers with a floating point in this project. However, there were no resources to systematically verify the sources. As a result of the check, it became clear that it was necessary to give the developer something to broaden his horizons in terms of working with floating point numbers. He's been linked to a couple of good articles. We'll see how things turn out. It is difficult to say for sure whether this error causes real disruptions in the program. The current solution exposes a number of requirements for the original polygonal mesh of arteries, which simulates the spread of X-ray contrast matter. If the requirements are not met, the program may fall, or the work is clearly incorrect. Some of these requirements are obtained analytically, and some - empirically. It is possible that this empirical bunch of the requirements is growing just because of incorrect handling of numbers with a floating point. It should be noted that not all found cases of using precise comparison of numbers with a floating point were an error.

As you can see, what is not interesting in some projects is of interest in others. This makes it impossible to create a list of the "most interesting" ones.

Note. You can also set the level of warnings using settings. For example, if you think that the V550 diagnostic deserves close attention, you can move it from Level 3 to the 1 one. This type of settings is described in the documentation (see "How to Set Your Level for Specific Diagnostics").



Now you know how to start studying analyzer warnings by looking at the most interesting ones. And don't forget to look into the documentation to get a detailed description of warnings. Sometimes it happens that behind a nondescript, at first glance, warning lies hell. An example of such diagnostics: V597, V1026. Thank you for your attention.

Popular related articles
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…
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
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…
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…
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…
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…
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…
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…
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 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 →