Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V6005. The 'x' variable is assigned...
menu mobile close menu
Additional information
toggle menu Contents

V6005. The 'x' variable is assigned to itself.

May 04 2018

The analyzer has detected a potential error: a variable is assigned to itself.

The example:

void change(int width, int height, int length)
{
  this.mWidth = width;
  this.mHeight = height;
  this.mLength = this.mLength;
}

The values of an object's properties are intended to be changed according to the method parameters, but mistakenly assigned its own value to the mLength instead of the length argument's value.

The fixed code:

void change(int width, int height, int length)
{
  this.mWidth = width;
  this.mHeight = height;
  this.mLength = length;
}

This diagnostic is classified as:

  • CERT-MSC56-J

You can look at examples of errors detected by the V6005 diagnostic.