The following statement does not really make sense:
value = value--;
I accidentially wrote this instead of just value-- or value = value-1 . But since it worked on my machine as intended, the error was not noticed.
Now I want to know, if this statement is well defined and will have the same result on all machines. Or can this lead to different results?
No, this is not well-defined, even in C++17. (Assuming built-in
=, not a function call). The assignment to the left side is sequenced-after the calculation of the value on the right side. But the side effects of the right-hand side (value--) are not sequenced relative to the assignment. And decrementingvalueis a side effect ofvalue--.