The comma operator ',' is used to execute expressions to the both sides of it in the left-to-right order and get the value of the right expression.
The analyzer found an expression in code that uses the ',' operator in a suspicious way. It is highly probable that the program text contains a misprint.
Consider the following sample:
float Foo()
{
double A;
A = 1,23;
float f = 10.0f;
return 3,f;
}
In this code, the A variable will be assigned value 1 instead of 1.23. According to C/C++ rules, the "A = 1,23" expression equals "(A = 1),23". Also, the Foo() function will return value 10.0f instead of 3.0f. In the both cases, the error is related to using the ',' character instead of the '.' character.
This is the corrected version:
float Foo()
{
double A;
A = 1.23;
float f = 10.0f;
return 3.f;
}
Note. There were cases when the analyzer could not make out the code and generated V521 warnings for absolutely safe constructs. It is usually related to usage of template classes or complex macros. If you noted such a false alarm when working with the analyzer, please tell the developers about it. To suppress false alarms, you may use the comment of the "//-V521" type.
This diagnostic is classified as:
|
You can look at examples of errors detected by the V521 diagnostic. |