The order of evaluation of is not specified for this case in the standard and so you can not determine whether *p
or i++
will be evaluated first. The C99 draft standard says in section 6.5.2.2
Function calls paragraph 10 says:
The order of evaluation of the function designator, the actual arguments, and subexpressions within the actual arguments is unspecified, but there is a sequence point before the actual call.
This is also undefined behavior because you are modifying i
and accessing the previous value of i
in another expression within the same sequence point, the draft standard in section 6.5
Expressions paragraph 2 says:
Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression.72) Furthermore, the prior value shall be read only to determine the value to be stored