V3112. 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 this example:

if (m_a != a || 
    m_b != b || 
    m_b != c) // <=
{
  ....
}

Because of the similarity of the variable names, there is a typo in the code. An error is located on the third line. The variable 'c' should be compared with 'm_c' rather than with 'm_b'. It is difficult to notice the error even when reading this text. Please, pay attention to the variable names.

The right variant:

if (m_a != a || 
    m_b != b || 
    m_c != c) // <=
{
  ....
}

If the analyzer issued the warning V3112, 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.

You can look at examples of errors detected by the V3112 diagnostic.


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;