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 6.26 Released

PVS-Studio 6.26 Released

Oct 18 2018

Normally we don't write notes about a release of the new version of PVS-Studio. However, this new release included many interesting improvements related to analysis of C and C++ code, about which we'd like to tell our users.


Java is Coming Soon

Frankly speaking, the latest and most exciting upgrades in PVS-Studio are still hidden. I mean support of the Java programming language by the analyzer. We haven't released a public PVS-Studio beta-version for Java yet, but it will be available very soon. If someone wants to take part in its testing, you can write to our support (choose: I want the analyzer for Java).

New Diagnostics for C and C++

In the new version we slightly got carried away and added immediately 15 general-purpose diagnostics for C and C++ (V1021-V1035). In a minor release, we've never added as many diagnostics at once. More details on each of the diagnostics can be found in the documentation. In my opinion, the most interesting ones among the new diagnostics are:

  • V1026. The variable is incremented in the loop. Undefined behavior will occur in case of signed integer overflow.
  • V1033. Variable is declared as auto in C. Its default type is int.

The V1026 diagnostic is created based on the discussion (RU) at the forum. A programmer complained about GCC 8 compiler bug, but it turned out, that the reason of it was incorrect code, resulting in undefined behavior. Let's consider this case.

Note. In the original discussion, the variable s is of the type const char *s. In doing so, on the target platform the char type is unsigned. So for clarity, I immediately wrote in the example that a pointer type is const unsigned char *.

int foo(const unsigned char *s)
  int r = 0;
  while(*s) {
    r += ((r * 20891 + *s *200) | *s ^ 4 | *s ^ 3) ^ (r >> 1);
  return r & 0x7fffffff;

The compiler does not generate code for the bitwise AND (&) operator. That's why the function returns negative values, although according to the idea of a programmer, this mustn't happen.

A developer believes that this is a bug in the compiler. Nevertheless, it is the author of the code who is wrong. The function does not work correctly due to the fact that undefined behavior occurs in it.

The compiler follows that in the r variable a certain sum is calculated. Overflow of the r variable must not happen. Otherwise, it is undefined behavior, which doesn't have to be considered or taken into account by a compiler. So, the compiler thinks that since the value of r variable after ending the loop cannot be negative, then r & 0x7fffffff operation is not needed to reset the sigh bit and the compiler just returns the value of r variable from the function.

It is the V1026 diagnostic that is designed to detect such errors. To fix the code, it is enough to read hash using an unsigned variable for this. Correct code variant:

int foo(const unsigned char *s)
  unsigned r = 0;
  while(*s) {
    r += ((r * 20891 + *s *200) | *s ^ 4 | *s ^ 3) ^ (r >> 1);
  return (int)(r & 0x7fffffff);

Now let's look at another diagnostic V1033. It is interesting because of the fact that the reason of possible errors was the new keyword auto introduced in C++11. However, not the C++11 innovation is to blame, but some psychological nuances :). Now let me explain. Take a look at this code:

float d = 3.14f;
int i = 1;
auto sum = d + i;

Did you notice an error in it? Think for a while. Here's a picture so you don't read the text immediately.


Guess what might be wrong? If not, here is some more interesting information. The sum variable will be equal to 4 instead of 4.14. Why?


Now a reader is going to say that it was an unfair riddle! The thing is that this is not C++, but C.

It so happens a project contains C++ and oldy worldy C. The programmer gets used to using auto in C++ and accidentally can use this keyword in C. But there, it means something quite different:


Defines a local variable as having a local lifetime. Keyword auto uses the following syntax:

[auto] data-definition;

As the local lifetime is the default for local variables, auto keyword is extremely rarely used.

It turns out that the sum variable has the int type, which is why its value will be equal to 4.


Even though the error may seem exotic, actually, in the project, which uses a mixture of C and C++ files, it can be make very easily. Accordingly, when analyzing C files, PVS-Studio warns about such suspicious constructions.

Other New Features

The ability to check projects for a Waf build system is added.

We continue to develop the analyzer towards embedded systems. In this version we added support for checking projects aimed to be built GNU Arm Embedded Toolchain, Arm Embedded GCC compiler.

When analyzing projects for Visual C++ compiler (cl.exe, vcxproj projects for Visual Studio/Standalone), in the analyzer report the case is preserved in paths to checked files. Refinement looks simpler than it is in reality. When preprocessing files, the cl.exe compiler spoils the case in file names. So we have to restore them back in the analyzer.

We also added the ability to use pvsconfig files with CLMonitor/Standalone on Windows.

Incremental analysis mode is added for pvs-studio-analzyer/CMake module. PVS-Studio CMake module can now be used on Windows for projects built with the Visual C++ compiler (cl.exe).

Incremental analysis support for .NET Core/.NET Standard Visual Studio projects is now available.

Additional Links

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…
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…
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…
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…
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…
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…
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…
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…

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 →