Let's see the official descriptions here to get a deeper understanding.
For the postfix operator, quoting C11
, chapter §6.5.2.3
The result of the postfix ++
operator is the value of the operand. As a side effect, the
value of the operand object is incremented (that is, the value 1 of the appropriate type is
added to it). [...] The value computation of the result is sequenced before the side effect of
updating the stored value of the operand.
and, regarding the function call, chapter §6.5.2.3
There is a sequence point after the evaluations of the function designator and the actual
arguments but before the actual call. Every evaluation in the calling function (including
other function calls) that is not otherwise specifically sequenced before or after the
execution of the body of the called function is indeterminately sequenced with respect to
the execution of the called function.
So, as per above description, there's nothing problematic in your code as shown above.
The old value of x
is passed and then, the value is increased.
However, please note the last part of the second quote, you need to maintain the sanity of the code. For example, you need to make sure, there's no change in value without having a sequence point in between. Something like
foo(x++, x++, y);
will be a problem as, you're trying to changing the same variable (x
) more than once.