From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123204 invoked by alias); 12 Apr 2015 20:59:21 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 123158 invoked by uid 48); 12 Apr 2015 20:59:16 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/60519] Debug mode should check comparators for irreflexivity Date: Sun, 12 Apr 2015 20:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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-SW-Source: 2015-04/txt/msg01003.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D60519 --- Comment #3 from Jonathan Wakely --- (In reply to Fran=C3=A7ois Dumont from comment #2) > So yes it doubles the number of comparisons which is definitely a Well actually your patch doesn't double the number, because you only do the reverse check when the first check returns true. > performance hint but your patch on the other hand expect to detect an > implementation issue on only 1 use case so it can miss many kind of wrong > implementation on special instances. The most common mistake I want this to detect is simply trying to define something equivalent to operator<=3D instead of operator< (see PR 59391 tha= t I linked to) and that will be detected for every value, so you only need to c= heck the first one. i.e. I want to check for irreflexivity. Your patch checks for antisymmetry instead, which is also required for a st= rict weak order, but is a different property. Checking for antisymmetry is necessary to check broken orders like this: bool cmp(const pair& l, const pair& r) { return l.first < r.first || l.second < r.second; } Your patch also only works for C++11, but there's no reason this shouldn't = work for C++03 too. Which algorithms benefit from handling heterogeneous types in these checks? >>From gcc-bugs-return-483452-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Apr 12 21:03:13 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 129702 invoked by alias); 12 Apr 2015 21:03:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 129635 invoked by uid 48); 12 Apr 2015 21:03:09 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/60519] Debug mode should check comparators for irreflexivity Date: Sun, 12 Apr 2015 21:03:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg01004.txt.bz2 Content-length: 473 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60519 --- Comment #4 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #3) > Your patch checks for antisymmetry instead, which is also required for a > strict weak order, but is a different property. Maybe we want both, because the irreflexivity check can be done very cheaply, so is suitable for the Debug Mode Lite I've talked about, but the antisymmetry check is more expensive.