vendredi 3 juillet 2020

about clang unsequenced warning

I cannot understand why the following code will generate unsequenced warning when compile with clang

int a=2;
a+=a-=2;

as a comparison , I can understand the following which also generate the same warning

int i=1;
i = i++ + i;

since i could be 2 or 3 (operator + is unseqnenced per C++ standard), and the warning makes sense, but for a, it seems it will always be 0 , there is no indetermination, the warning makes no sense. Please help. Many thanks!

Aucun commentaire:

Enregistrer un commentaire