This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgomp/65589] OpenMP 3.1 produces random results for simple array copy
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 26 Mar 2015 18:57:00 +0000
- Subject: [Bug libgomp/65589] OpenMP 3.1 produces random results for simple array copy
- Auto-submitted: auto-generated
- References: <bug-65589-4 at http dot gcc dot gnu dot org/bugzilla/>
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.