I am wondering about the following situation:
void f(int a, int b) { }
int a(int x) { std::cout << "func a" << std::endl; return 1; }
int b(int x) { std::cout << "func b" << std::endl; return 2; }
int x() { std::cout << "func x" << std::endl; return 3; }
int y() { std::cout << "func y" << std::endl; return 4; }
f(a(x()), b(y()));
After reading http://en.cppreference.com/w/cpp/language/eval_order I am still having difficulty to understand whether the following evaluation order is possible:
x()
-> y()
-> a()
-> b()
or that the standard guarantees that a(x())
and b(y())
will be evaluated as units, so to speak.
In other words, is there any possibility this will print
func x
func y
func a
func b
Running this test on GCC 5.4.0 gives the to my mind more logical
func y
func b
func x
func a
but this of course does not tell me anything about what the standard requires. It would be nice to get a reference to the standard.