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.

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-1164.

Bugs Found

Checked Projects
Collected Errors
13 764