The accepted answer in the marked duplicate is Incorrect.
f(a,a++,a++);
Causes Undefined behavior. It tries to modify the argument a
without an intervening sequence point. Also, it is important to note that order of evaluation of function arguments is Unspecified. It can be:
- Left to Right or
- Right to Left or
- Any magical order the compiler chooses.
If you are using GCC you can use the warning flag -wsequence-point
to warn you of sequence point related undefined behaviors.
In GCC If you compile your program at strictest warning levels, the compiler will give you this diagnostic:
prog.c:10:18: error: operation on ‘a’ may be undefined [-Werror=sequence-point]
prog.c:10:18: error: operation on ‘a’ may be undefined [-Werror=sequence-point]
Reference:
C99 Standard §6.5.2.2:
Para 10:
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.
Note that the quote only says that there is a sequence point before the actual function call, it does not imply there is a sequence point between evaluation of subexpression arguments.