PVS-Studio 6.16 released

PVS-Studio is a static code analyzer that detects errors and potential vulnerabilities in the source code of programs written in C/C++/C#. Version 6.16 has obtained 11 new general analysis diagnostics.

djjCz8xuPV4

  1. V789. Iterators for the container, used in the range-based for loop, become invalid upon a function call.
  2. V790. It is odd that the assignment operator takes an object by a non-constant reference and returns this object.
  3. V791. The initial value of the index in the nested loop equals ‘i’. Consider using ‘i + 1’ instead.
  4. V792. The function located to the right of the ‘|’ and ‘&’ operators will be called regardless of the value of the left operand. Consider using ‘||’ and ‘&&’ instead.
  5. V793. It is odd that the result of the statement is a part of the condition. Perhaps, this statement should have been compared with something else.
  6. V794. The copy operator should be protected from the case of this == &src.
  7. V795. Note that the size of the ‘time_t’ type is not 64 bits. After the year 2038, the program will work incorrectly.
  8. V796. A ‘break’ statement is probably missing in a ‘switch’ statement.
  9. V797. The function is used as if it returned a bool type. The return value of the function should probably be compared with std::string::npos.
  10. V798. The size of the dynamic array can be less than the number of elements in the initializer.
  11. V799. The variable is not used after memory has been allocated for it. Consider checking the use of this variable.

And three diagnostics for microoptimization:

  1. V818. It is more efficient to use an initialization list rather than an assignment operator.
  2. V819. Decreased performance. Memory is allocated and released multiple times inside the loop body.
  3. V820. The variable is not used after copying. Copying can be replaced with move/swap for optimization.

In a sense, this is a milestone for us. The thing is that we cannot add more numbers of general analysis warnings, otherwise they will concur with the numbers of micro-optimization diagnostics. It seemed to us that the list of 300 diagnostics was endless, but now it is over and we got to the point of 800, where we have micro-optimization diagnostics. In the next release we plan to resume numbering the general-analysis warnings with V1000.

Besides creating new diagnostics, we improve the already existing diagnostics. This time the improvements were made in the following diagnostics: V512, V519, V522, V558, V575, V576, V586, V591, V597, V601, V607, V611, V630, V641, V675, V676, V724, V728, V730, V769, V773, V779.

We made several edits allowing to check the code of the Tizen operating system. We will go back to the check of Tizen many times. Soon there will be at least 2 articles on this topic.

I suggest downloading the new version of the analyzer: https://www.viva64.com/en/pvs-studio-download/?win

An always up-to-date list of articles describing errors that we find in open source projects with PVS-Studio analyzer – https://www.viva64.com/en/inspections/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s