A few updates on the results of my “poser” post.
First, anybody who said “anybody who coded that deserves whatever they get” is absolutely correct, but gets no points because that wasn’t the answer we were looking for.
I thought it was an interesting question for two reasons (most of which Wes covered in his response, but you may not have read it).
First, when you write:
x += 5;
the compiler write this as
x = x + 5;
which obviously changes the order of evaluation, and the answer to the question.
The second is that C# evaluates from left to right, so you can reason about how expressions are evaluated.
In C++, it’s implementation-defined, and you truly get what you deserve.