Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V722. Abnormality within similar...
menu mobile close menu
Additional information
toggle menu Contents

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

May 03 2015

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.

This diagnostic is classified as: