I use the streaming operators (e.g. operator<<(const char*)
) for logging. In my unit tests I have a test like the following:
MyLogger oLogger;
This is acceptable behaviour, as it is not specified in which order operands to "operator<<" are being evaluated, and TTBOMK gcc often does it in reverse order to get the parameters onto the stack in the right order for the next function call.
Think of it in terms of a stack machine:
push "charly"
push oLogger
call operator<<
pop
push "bar"
push 10
call sleep
push "foo"
push oLogger
call operator<<
call operator<<
call operator<<
pop