Pete said:
Ask whoever said it.
Generally speaking, neither the C nor the C++ standard imposes any
requirements on code used in multi-threaded applications, so it's
vacuously true that nothing in either language is thread safe. More
usefully, though, compiler writers and library writers generally know
that people sometimes write multi-threaded applications (even when they
shouldn't, but that's a separate discussion), and take reasonable care
to ensure that their code works "correctly" in multiple threads. Ask
your vendor what "correctly" means.
POSIX defines "Reentrant Function": "A function whose effect, when
called by two or more threads, is guaranteed to be as if the threads
each executed the function one after another in an undefined order,
even if the actual execution is interleaved" (just like everything,
it holds as long as application doesn't trigger undefined behavior
[for example by using pointer arguments which lead to violation of
XBD 4.10]). With respect to rand(), it says "The rand() function need
not be reentrant. A function that is not required to be reentrant is
not required to be thread-safe.". Under TSF option, POSIX provides
"thread-safe" rand_r() function.
regards,
alexander.