From: Jakub Jelinek <jakub@redhat.com>
To: Yury Gribov <y.gribov@samsung.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Andrey Belevantsev <abel@ispras.ru>,
Andrew MacLeod <amacleod@redhat.com>,
Andrew Pinski <pinskia@gmail.com>,
Diego Novillo <dnovillo@google.com>,
Geoff Keating <geoffk@geoffk.org>,
Jason Merrill <jason@redhat.com>,
Richard Biener <rguenther@suse.de>,
Steven Bosscher <steven@gcc.gnu.org>
Subject: Re: [PATCH 1/5] Fix asymmetric comparison functions
Date: Fri, 18 Dec 2015 20:07:00 -0000 [thread overview]
Message-ID: <20151218200700.GB18720@tucnak.redhat.com> (raw)
In-Reply-To: <56746138.9070709@samsung.com>
On Fri, Dec 18, 2015 at 10:40:40PM +0300, Yury Gribov wrote:
> So it seems most people generally agree that self-comparisons (cmp(x,x) ==
> 0) are useless and don't need to be checked or fixed. What about ensuring
> symmetry i.e. that cmp(x, y) == -cmp(y, x) forall x, y? One of the bugs
> (pair_cmp in fortran/interface.c) is exactly about this.
Ensuring symmetry for x != y is of course very much desirable.
So, if you could change your qsort interposer so that it for each comparison
x != y calls both cmp (x, y) and cmp (y, x) and asserts that
int r = cmp (x, y);
int ir = cmp (y, x);
if (r > 0) assert (ir < 0);
else if (r < 0) assert (ir > 0);
else assert (ir == 0);
it would be greatly appreciated. Note, the standard only talks about < 0, 0
and > 0, so it is fine if cmp (x, y) returns 231 and cmp (y, x) returns -142.
Jakub
next prev parent reply other threads:[~2015-12-18 20:07 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 8:55 [PATCH 0/5] Fix qsort " Yury Gribov
2015-12-17 8:58 ` [PATCH 1/5] Fix asymmetric " Yury Gribov
2015-12-17 11:39 ` Jakub Jelinek
2015-12-17 12:04 ` Yury Gribov
2015-12-18 19:40 ` Yury Gribov
2015-12-18 20:07 ` Jakub Jelinek [this message]
2015-12-18 20:09 ` Yury Gribov
2015-12-17 11:41 ` Richard Biener
2015-12-17 11:47 ` Yury Gribov
2015-12-17 11:57 ` Jakub Jelinek
2015-12-17 11:59 ` Richard Biener
2015-12-17 12:14 ` Yury Gribov
2015-12-17 12:25 ` Richard Biener
2015-12-17 12:36 ` Yury Gribov
2015-12-17 11:59 ` Andrey Belevantsev
2015-12-17 12:12 ` Yury Gribov
2015-12-17 12:48 ` Andrey Belevantsev
2015-12-17 19:39 ` Andrew Pinski
2015-12-17 22:00 ` Jason Merrill
2015-12-17 8:59 ` [PATCH 2/5] Fix more " Yury Gribov
2015-12-17 9:00 ` [PATCH 3/5] "Fix" intransitive comparison in reload_pseudo_compare_func Yury Gribov
2015-12-17 19:36 ` Vladimir Makarov
2015-12-18 19:50 ` Yury Gribov
2015-12-17 9:02 ` [PATCH 4/5] Fix intransitive comparison in compare_access_positions Yury Gribov
2015-12-17 14:58 ` Martin Jambor
2015-12-17 9:03 ` [PATCH 5/5] Fix intransitive comparison in dr_group_sort_cmp Yury Gribov
2015-12-17 11:57 ` Richard Biener
2015-12-17 12:33 ` Yury Gribov
2015-12-17 12:51 ` Richard Biener
2015-12-18 20:19 ` Yury Gribov
2015-12-18 22:30 ` Yuri Gribov
2015-12-25 11:42 ` Yury Gribov
2016-01-08 8:23 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151218200700.GB18720@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=abel@ispras.ru \
--cc=amacleod@redhat.com \
--cc=dnovillo@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=geoffk@geoffk.org \
--cc=jason@redhat.com \
--cc=pinskia@gmail.com \
--cc=rguenther@suse.de \
--cc=steven@gcc.gnu.org \
--cc=y.gribov@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).