Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V8011. An identical expression to...
menu mobile close menu
Additional information
toggle menu Contents

V8011. An identical expression to the left and to the right of a compound assignment.

Apr 03 2026

The analyzer has detected that identical expressions surround a compound assignment operator. The operation may be incorrect and redundant, or it can be simplified.

The example:

x -= x - 5

In this case, the expression assigns the 5 value to the x variable. Most likely, the intended operation is to subtract 5 from the x variable.

The fixed code:

x = x - 5

Another option:

x -= 5

The diagnostic rule also applies to the following operators: +=, *=, /=, and %=.