Line of code in C
x = x |= (1 << 3);
which gives the cppCheck error: "Expression" x = x | = 1 'depends on the order of evaluation of side effects "
whereas the string
x |= (1 << 3);
fine.
I thought that
x = x |= (1 << 3);
same as
x = x = x | (1 << 3);
which is just
x = (x = (x | (1 << 3)));
where in fact the external assignment x has no effect, which means that the result is the same as
x |= (1 << 3);
So what is the CppCheck complaint here?
edit: think this is a duplicate of why it j = j++is or does not coincide with j++which is discussed in the question mentioned above.
source
share