x = x + (xPP) + x = 10 "11" 11 "32
in the last x, because xPP has been executed before, the x has changed.
Xbox = xPP+x;
according to the greedy matching principle of the c language, it will be considered as x = (xPP) + x = 11 at + =, xPP+x is 10: 11, and finally should be 11: 10: 11, but this is my own guess, this behavior of modifying the value of variables many times in an expression is that ub, can have different results due to different compilers.
The
post operator PP does not complete the + 1 operation on the variable until the end of the execution of the whole statement, but the variable State and the operator PP, so state + = (statePP) + state, is equivalent to 11 + = 10 + 11. In the end, it equals 32.
In fact, you can understand this question by disassembling it. The high-level language h
ides a lot of implementation details, and taking a look at the assembly can give you a clearer understanding. To put it bluntly, the compiler h
ides the processing details of different grammar too deeply. Officially, there are grammar and related spec, but some abstractions are not as convenient as disassembly.
in order to deepen understanding, you can, but should avoid such code, the readability is too poor.
my understanding: X = x + (xPP) + x = (x + (xPP)) + x) = 10 "11" 11 "32; parenthesis operation is the highest, the first x is 10, the last x is 11;