From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A886386EC68; Tue, 12 Jan 2021 10:13:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A886386EC68 From: "tilps at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98632] New: Warn about unspecified expression ordering for atomics with non-relaxed memory ordering. Date: Tue, 12 Jan 2021 10:13:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tilps at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Jan 2021 10:13:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98632 Bug ID: 98632 Summary: Warn about unspecified expression ordering for atomics with non-relaxed memory ordering. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tilps at hotmail dot com Target Milestone: --- C++ defines that execution ordering for expressions is largely unspecified.= In cases where there are multiple atomic operations in an expression for which there is no standard required ordering, and if those atomic operations are marked with a non-relaxed memory ordering, it would be useful to have a warning. Since the compiler is technically free to reorder them in-spite of= the memory ordering indicating that the user cares about the specific ordering. While it might be able to be argued that the warning should fire for any expression involving just a single atomic and some other expression compone= nt that would be unable to be reordered if the sub-expressions had been assign= ed to locals first, it seems that would be likely to have vastly more false positives than expressions that involve multiple atomic operations. So I wo= uld suggest only triggering for expressions involving multiple atomic operation= s.=