V722. An abnormality within similar comparisons. It is possible that a typo is present inside the expression.

The analyzer found suspicious condition that may contain an error. The diagnosis is empirical, that is why it is easier to demonstrate it on the example than to explain the working principle of the analyzer. Consider the real example:

if (obj.m_p == p &&
    obj.m_forConstPtrOp == forConstVarOp &&
    obj.m_forConstPtrOp == forConstPtrOp) 

Because of the similarity of the variable names, there is a typo in the code. An error is located on the second line. The variable 'forConstVarOp' should be compared with 'm_forConstVarOp' rather than with 'm_forConstPtrOp'. It is difficult to notice the error even when reading this text. Please, pay attention to 'Var' and 'Ptr' within the variable names.

The right variant:

if (obj.m_p == p &&
    obj.m_forConstVarOp == forConstVarOp &&
    obj.m_forConstPtrOp == forConstPtrOp)

If the analyzer issued the warning V722, then carefully read the corresponding code. Sometimes it is difficult to notice a typo.

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

Bugs Found

Checked Projects
Collected Errors
12 668