V3060. A value of variable is not modified. Consider inspecting the expression. It is possible that other value should be present instead of '0'.

The analyzer detected a suspicious bitwise expression. This expression was meant to change certain bits in a variable, but the value this variable refers to will actually stay unchanged.

Consider the following example:

A &= ~(0 << Y);
A = A & ~(0 << Y);

The programmer wanted to clear a certain bit in the variable's value but made a mistake and wrote 0 instead of 1.

Both expressions evaluate to the same result, so let's examine the second line as a clearer example. Suppose we have the following values of the variables in bit representation:

A = 0..0101

A = 0..0101 & ~(0..0000 << 0..00001)

Shifting the value 0 by one bit to the left won't change anything; we'll get the following expression:

A = 0..0101 & ~0..0000

Then, the bitwise negation operation will be executed, resulting in the following expression:

A = 0..0101 & 11111111

After executing the bitwise "AND" operation, the original and resulting expressions will turn out to be the same:

A = 0..0101

The fixed version of the code should look like this:

A &= ~(1 << Y);
A = A & ~(1 << Y);

This diagnostic is classified as:

Bugs Found

Checked Projects
Collected Errors
14 526
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →