https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102698
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Your testcase is racy and therefore anything can happen. Please see https://www.openmp.org/spec-html/5.1/openmpsu105.html#x138-1480002.19.7 "Only the read and write of the location designated by x are performed mutually atomically. Neither the evaluation of expr or expr-list, nor the write to the location designated by v, need be atomic with respect to the read or write of the location designated by x." But the testcase is expecting that the store to o(idx(i), idy(i)) will be atomic and done whenever the atomic or succeeds. That is not the case, the store is done after the atomic or succeeded, but using a normal store instruction and other threads can store the same location in between (e.g. even though they performed the atomic instruction later, they can store the result earlier).