V1048. Variable 'foo' was assigned the same value.

The analyzer has detected a case where a variable is assigned the value already stored in it. Such an assignment is very likely to be a logic error.

Consider the following example:

int i = foo();
if (i == 0)
{
  i = 0;      // <=
}

The reported assignment does not change the value of the variable, and the code is apparently faulty.

The analyzer can also detect cases where exact values of variables are unknown:

void foo(int x, int y)
{
  if (x == y)
  {
    x = y;    // <=
  }
}

Even though the variables 'x' and 'y' can take any values, the assignment is still meaningless because of the earlier condition checking these variables for equality.

This diagnostic is classified as:

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


Bugs Found

Checked Projects
412
Collected Errors
14 132
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