V2007. This expression can be simplified. One of the operands in the operation equals NN. Probably it is a mistake.

This diagnostic message was added on users' request.

The analyzer allows you to detect some strange binary operations:

  • operations '^', '+', '-', '<<', '>>' where one of the operands equals 0;
  • the '&' operation where one of the operands equals -1;
  • operations '*', '/', '%' where one of the operands equals 1;

The V2007 diagnostic rule helps to perform code refactoring and sometimes detect errors.

These are examples of constructs that cause this diagnostic message to appear:

int X = 1 ^ 0;
int Y = 2 / X;

This code can be simplified. For example:

int X = 1;
int Y = 2;

To reduce the number of false positives, we have added several exceptions. For example, the V2007 diagnostic message is not generated when the strange expression is located inside a macro or is an array index.

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

Bugs Found

Checked Projects
Collected Errors
12 668