From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 42FB5385783D; Tue, 12 Oct 2021 08:14:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42FB5385783D From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102698] omp atomic capture Abnormal results after running multiple times Date: Tue, 12 Oct 2021 08:14:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2021 08:14:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102698 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #2 from Jakub Jelinek --- 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 mutu= ally atomically. Neither the evaluation of expr or expr-list, nor the write to t= he 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 resu= lt earlier).=