CppCheck warning: the expression depends on the evaluation order at x = x | = (1 << 3)

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.

+4
source share
1

@Cornstalks .

... , , (, , , .. , do, ).

C , , .

& :

x = x |= 1 x = x += 1 ( x). x = x += 1 x = ++x C. undefined.

[]

+3

Source: https://habr.com/ru/post/1628862/


All Articles