V607. Ownerless expression 'Foo'.
The analyzer has detected a potentially redundant expression. Such constructs may occur when the result of a variable assignment, method call, operator, or similar operation is never used. Such cases may occur as the result of incomplete refactoring.
The example:
void Run(int &a, int b, int c, bool X)
{
if (X)
a = b + c;
else
b - c;
}
The program text is incomplete because of a typo. It compiles well but has no practical sense.
The fixed code:
void Run(int &a, int b, int c, bool X)
{
if (X)
a = b + c;
else
a = b - c;
}
Another example:
typedef struct data_format {
int day;
int month;
};
In this case, the typedef keyword is used incorrectly because no alias name is specified for the declared type. As a result, it does not perform its intended function and is redundant.
The fixed code:
typedef struct data_format {
int day;
int month;
} data_format_t; //< = Added alias for typedef
Exceptions:
The analyzer does not report redundant constructs in certain cases, such as when a compiler warning about unused variables is deliberately suppressed:
void Foo(int a, int b)
{
a, b;
}
In this example, the analyzer does not issue the V607 warning.
This diagnostic is classified as:
You can look at examples of errors detected by the V607 diagnostic. |