Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
>
>
>
V2007. This expression can be...
menu mobile close menu
Additional information
toggle menu Contents

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

09 Nov 2012

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: