Quote Originally Posted by John E View Post
But what if 'x' was a local variable...?

Code:
int some_func()
{
int x;

      x = call_some_other_func();

      return x;
}
Assuming that 'call_some_other_func()' was thread safe, is it safe to call the above function from two unsynchronised threads? Does each of them see a different copy of x?
Considering the fact that after some_func scope is left local x is invalid and unreachable, and only returned copy remains on the stack... than yes, it is thread safe to be used in multithreaded app, as the return value exists only in the scope of a caller, and therefore no other thread is able to access it.