Here is a question I can not explain clearly.
Which option is wrong and why?
(A) a += (a++);
(B) a += (++a);
(C) (a++) += a;
(D) (++a) += (a++);
What is the difference between A
and B
?
My understand:
A
is a UB but B
is OK because the side effect of ++a
will be completed before the assignment. Is that right?
Update: What is the difference between ++a
and a++
within the sequence point? The side effect of pre-increment(decrement) may be completed any time before the next seq-point just like post-increment(decrement)?