Macros perform text replacement. MAX(x++, y++) expands to ((x++) < (y++) ? (y++) : (x++)). In fact, using MAX with expressions with side effects (i.e. expressions that modify the contents of memory) has undefined behavior.
To avoid these problems, use actual functions. std::max in <algorithm> is a drop-in replacement for MAX that will behave nicely with side effects.
In fact, using MAX with expressions with side effects (i.e. expressions that modify the contents of memory) has undefined behavior.
Not in this case with the ternary operator because every value computation and side effect associated with the first expression is sequenced before every value computation and side effect associated with the second or third expression (ยง5.16/1).