I was reading this question and then I made the following.
a = b + (c - (b = c)) + (a - (c = a))
I tried that in C and Java. It works with java , but not C.
Of course, it depends on how the compiler evaluate such expressions and after googling about that, I failed to find the answer.
The reason why it doesn’t work in C is because C doesn’t specify exactly when the
c = awill occur. It can occur before or after the two other times it is referenced in that statement.So depending on when the compiler decides to perform the assignment
c = a, the value of the expression will vary. It’s not defined.i.e. If
b = cis evaluated beforec = athen,bwill take the original value ofc. If it is evaluated after, then it will take the value ofa.