foo() can be executed before or after a/2, and the order may change the second time you evaluate the same line of code. C++ (or C for that matter) has no order of evaluation (except for a few special cases)
Incidentally, you have an error: main() cannot return void and foo() must return something in order for those expressions to compile.