[Bug libgomp/65589] OpenMP 3.1 produces random results for simple array copy

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 26 19:18:00 GMT 2015


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.



More information about the Gcc-bugs mailing list