﻿# V3107\. Identical expression to the left and to the right of compound assignment\.

The analyzer detected identical subexpressions to the left and to the right of a compound assignment operator\. This operation may be incorrect or meaningless, or can be simplified\.

Consider the following example:

```cpp
x += x + 5;
```

Perhaps the programmer simply wanted to add the value 5 to the 'x' variable\. In that case, the fixed code would look like this:

```cpp
x = x + 5;
```

Or perhaps they wanted to add the value 5 but wrote an extra 'x' variable by mistake\. Then the code should look like this:

```cpp
x += 5;
```

However, it is also possible that the code is written correctly, but it looks too complicated and should be simplified:

```cpp
x = x * 2 + 5;
```

Now consider the following example:

```cpp
x += x;
```

This operation is equivalent to multiplying the value of a variable by two\. This is what a clearer version would look like:

```cpp
x *= 2;
```

Here is one more expression: 

```cpp
y += top - y;
```

We are trying to add the difference of the variables 'top' and 'y' to the 'y' variable\. Resolving this expression produces the following result:

```cpp
y = y + top – y;
```

It can be simplified, as the 'y' variable is subtracted from itself, which does not make sense:

```cpp
y = top;
```