https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68705
Bug ID: 68705 Summary: libgomp.c/sort-1.c/sort missing synchronization Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: testsuite Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Created attachment 36927 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36927&action=edit libgomp.c/sort-1.c:sort1 Consider libgomp.c/sort-1.c:sort1 (attached). There's a bit of code only performed by thread 0: ... if (omp_get_thread_num () == 0) { num_threads = omp_get_num_threads (); hi = count - 1; idle = false; } ... It initializes shared variable num_threads. This num_threads variable is used by all threads subsequently, but there doesn't seem to be a mechanism present that guarantees that the initialization by thread 0 is done before any other thread reads the value (). Looking at similar testcases, it seems omp barrier is used. Adding an omp barrier at the end of the snippet would add the missing synchronization.