V2007. This expression can be simplified. One of the operands in the operation equals NN. Probably it is a mistake.
This diagnostic rule was added at users' request.
The analyzer allows you to detect some strange binary operations where code can be simplified.
Suspicious binary operations are:
- 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.
This diagnostic is classified as: