https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65589
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > Note rand () is not thread-safe, so calling it from multiple threads > concurrently is undefined-behavior. Actually looking into glibc sources, you can notice there is a lock inside __random code. And this comment in the sources: /* POSIX.1c requires that there is mutual exclusion for the `rand' and `srand' functions to prevent concurrent calls from modifying common data. */ But everywhere else says rand is not thread safe.