Yes, this behavior is undefined - a and foo(--a) can be evaluated in any order.
For more information, see, for example, Sequence Point . There is a sequence point after the full expression and after evaluating the foo argument - but the order of evaluating the subexpressions is not specified, at 5/4:
Unless noted, the order of evaluation of the operands of individual operators and subexpressions are separate expressions and the order in which side effects occur is undefined. Between the previous and the next point in the sequence - the scalar object must have a stored value no more than once the evaluation of the expression. In addition, the previous value should only be accessed to determine the value to be stored. The requirements of this clause must be followed for each valid order of subexpression of the full expression; otherwise, the behavior is undefined.
EDIT: As Prasun points out, the behavior is unspecified due to the evaluation order ... not specified. and becomes undefined due to the previous value being reached only to determine the value that needs to be saved
source share