Reputation: 87959
Given a function call func(E1, E2, E3)
where E1 etc are arbitrary expressions, is it true that each expression is indeterminately sequenced with respect to each other expression, or are all the expressions unsequenced (i.e. the evaluations can overlap)?
I've looked at the cppreference page on this and it, in rule 15, uses the sentence
In a function call, value computations and side effects of the initialization of every parameter are indeterminately sequenced with respect to value computations and side effects of any other parameter.
which I don't think is quite the same as what I'm asking as the initialisation of the parameter is just the last step in evaluation of the parameter's expression.
But rule 21 which is talking about something else seems to imply that each sub-expression in a function call is indeterminately sequenced
Every expression in a comma-separated list of expressions in a parenthesized initializer is evaluated as if for a function call (indeterminately-sequenced)
So I'm a bit confused and any guidance is appreciated.
Upvotes: 5
Views: 295
Reputation: 14876
C++17 states in
8.2.2 Function call [expr.call]
4 ... The initialization and destruction of each parameter occurs within the context of the calling function.
5 ... Note: All side effects of argument evaluations are sequenced before the function is entered
5 ... The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter.
I hope this (my bolding) is clear enough.
(ref: n4659, final C++17 draft)
Upvotes: 5