No, the behavior is defined. To quote C++11 (n3337) [expr.comma/1]:
A pair of expressions separated by a comma is evaluated left-to-right;
the left expression is a discarded-value expression (Clause [expr]).
Every value computation and side effect associated with the left
expression is sequenced before every value computation and side effect
associated with the right expression.
And I take "every" to mean "every"1. The evaluation of the second x++
cannot happen before the call sequence to f
is completed and f
returns.2
1 Destructor calls aren't associated with sub-expressions, only with full expressions. So you'll see those executed in reverse order to temporary object creation at the end of the full expression.
2 This paragraph only applies to the comma when used as an operator. When the comma has a special meaning (such when designating a function call argument sequence) this does not apply.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…