From the holy standard:
Quote:ISO/IEC 14882:2003(E), Chapter 8: Declarators.
9. [...]The order of evaluation of function arguments is unspecified[...]
More information (Preliminary Note: Sequence points).
In this context, do not confuse the argument seperator with the sequence operator, which both happen to look the same (","), but are distinct. I mention this because according to Section 1.9, Item 18, the sequence operator as in
int a = foo(), bar();
forms a sequence point and it is defined which one is evaluated first, but in
foo(foo(), bar())
there is none, in one environment, foo() is evaluated first, in another it will be bar(), and on some, they might be exectued simultaneously.
Btw, Item 17 of 1.9 says this:
Quote:When calling a function (whether or not the function is inline), there is a sequence point after the evaluation of all function arguments (if any) which takes place before execution of any expressions or statements in the function body.
This basically means that in ...
void foo (int, int) { cout << "foo!\n"; } int main () { foo (frob(), y=3); }
... the expressions "frob()" and "y=3" are guaranteed to be evaulated before "cout << "foo!\n";" is reached. But the order of evaluation of "frob()" and "y=3" is
not defined.
Here's the rest of item 17, in case you are interested:
Quote:There is also a sequence point after the copying of a returned value and before the execution
of any expressions outside the function11). Several contexts in C + + cause evaluation of a function
call, even though no corresponding function call syntax appears in the translation unit. [Example: evaluation
of a new expression invokes one or more allocation and constructor functions; see 5.3.4. For another
example, invocation of a conversion function (12.3.2) can arise in contexts in which no function call syntax
appears. ] The sequence points at function-entry and function-exit (as described above) are features of the
function calls as evaluated, whatever the syntax of the expression that calls the function might be.