https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105030

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
something like

void *bar (void *x)
{
  *(double *)x = 1.;
}

void foo(int n)
{
   double atemp;
   pthread_create (..., bar, &atemp);
   for (int i = 0; i < n; i++)
     if (a[i] < atemp)
       atemp = a[i];
   pthread_join (...);
   if (atemp != 1.)
     abort ();
}

if it is ensured the store to atemp in the loop never takes place then
we have created a store data race when applying store motion.  Of course
thread creation/join can be hidden in other functions called from foo()
as long as 'atemp' escapes to callers.

Reply via email to