Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I am interested to try it on the platforms:
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si vous n'avez toujours pas reçu de réponse, vérifiez votre dossier
Spam/Junk et cliquez sur le bouton "Not Spam".
De cette façon, vous ne manquerez la réponse de notre équipe.

>
>
>
V6028. Identical expression to the left…
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Micro-Optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
toggle menu Contents

V6028. Identical expression to the left and to the right of compound assignment.

07 Mai 2018

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:

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:

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:

x += 5;

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

x = x * 2 + 5;

Now consider the following example:

x += x;

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

x *= 2;

Here is one more expression:

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:

y = y + top – y;

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

y = top;

You can look at examples of errors detected by the V6028 diagnostic.