In the last line of your code, you make several function calls (hidden, but each << operator is actually a function call). The evaluation of the parameters to these function calls is unspecified. So it is unspecified which "pop() function is called first.