Order of function calls is an c++ arithmetic operation

Viewed 45

Suppose we have this code (seen in an interview test), the order of arithmetical operations is well defined in the standard (left to right), but the question is: the order of execution for the functions is defined (the same as for the operations) or this code is undefined behavior?

int test_b = 1;
int test_x() {test_b++; return test_b;}
int test_y() {test_b = 3; return test_b - 1;}
int test_z() {test_b = test_b+8; return test_b + 2;}

int a = test_x() - test_y() + test_z();

Please keep in mind that this question is not related to sequence points (we have function calls)

PS: I have tried few online compilers on https://godbolt.org/, from what I have tested the result is always 13.

0 Answers
Related