The dereference happens first. This is the same thing as any other post-increment: the original value is used.
See, for instance, Post Increment with respect to Sequence Points
However, your question seems to be whether the function pointer use inside of foo()
will call foo()
or bar()
.
http://newsgroups.derkeiler.com/Archive/Comp/comp.std.c/2009-10/msg00053.html is a discussion in comp.std.c with the header "sequence point problem" that argues over precisely this point. I don't think it came to a consensus, but there were good arguments on both sides.
By my previous reading of the standard, this would invokes undefined behavior.
The call to a function acts as sequence point, but appendix C only says it acts as a sequence point relative to the expressions passed in as parameters -- they are guaranteed to be evaluated, but nothing else necessarily will (in f(i++) + g(j++)
accessing either i
in g()
or j
in f()
invokes undefined behavior.)
However, 6.5.5.2 (p 10) says:
There is a sequence point after the
evaluations of the function designator
and the actual arguments but before
the actual call.
which means that it does sequence the ++
.