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--
USD
EUR
GBP
RUB
* 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.

>
>
>
V813. Decreased performance. The argume…
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Diagnosis of micro-optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Additional information
Contents

V813. Decreased performance. The argument should probably be rendered as a constant pointer/reference.

Apr 29 2013

The analyzer has detected a construct that can be optimized: an argument, which is a structure or a class, is passed into a function by value. The analyzer checks the body function and finds out that the argument is not modified. For the purpose of optimization, it can be passed as a constant reference. It may enhance the program's performance, as it is only the address that will be copied instead of the whole class object when calling the function. This optimization is especially noticeable when the class contains a large amount of data.

For example:

void foo(Point p)
{
  float x = p.x;
  float y = p.y;
  float z = p.z;
  .... 'p' argument is not used further in any way....
}

This code is very easy to fix - you just need to change the function declaration:

void foo(const Point &p)
{
  float x = p.x;
  float y = p.y;
  float z = p.z;
  .... 'p' argument is not used further in any way....
}

The analyzer doesn't generate the warning if structures are very small.

Note N1. The user can specify the minimal structure size starting with which the analyzer should generate its warnings.

For example, to prevent it from generating messages for structures whose size is equal to or less than 32 bytes, you can add the following comment into the code:

//-V813_MINSIZE=33

The number 33 determines the structure size starting with which the analyzer will generate messages.

You can also write this comment in one of the global files (for example in StdAfx.h) so that it affects the whole project.

Default value: 9.

Note N2. The analyzer may make mistakes when trying to figure out whether or not a variable is being modified inside the function body. If you have noticed an obvious false positive, please send us the corresponding code sample for us to study it.

If the code is correct, you can turn off the false warning by adding the comment "//-V813".

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 →
Accept