The analyzer has detected a situation when a variable is initialized or assigned a new value which is expected to be checked in the condition of a subsequent 'if' statement but another variable is checked instead.
This error is demonstrated by the following example:
int ret = foo(....);
if (ret != -1) { .... }
....
int ret2 = bar(....);
if (ret != -1) { .... } // <=
Programmers often need to check the value returned by a function but use a wrong variable name in the condition of the 'if' statement. This mistake is typically made when you clone a code fragment but forget to modify the name of the variable in the condition. In the example above, the programmer forgot to change the name 'ret' to 'ret2'.
Fixed version:
int ret2 = bar(....);
if (ret2 != -1) { .... }
The following example also demonstrates this mistake:
this.data = calculate(data, ....);
if (data != -1) ....;
Both the variable and the field share the same name, which makes it easy to confuse one with the other.
This diagnostic is heuristic; it compares the names of the variables to conclude if there is a typo. It also performs a basic type check to reduce the number of false positives.
This diagnostic rule is classified as:
You can look at examples of errors detected by the V6080 diagnostic. |
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: