From: Alexander Monakov <amonakov@ispras.ru>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Richard Biener <richard.guenther@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 0/2] Introduce gcc_qsort
Date: Fri, 11 May 2018 12:16:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.20.13.1805111457000.1437@monopod.intra.ispras.ru> (raw)
In-Reply-To: <20180511111732.GD17342@gate.crashing.org>
On Fri, 11 May 2018, Segher Boessenkool wrote:
> > In general such address-based comparisons steps are invalid; they lack
> > anti-reflexivity. So comparators are not actually allowed to do that.
>
> I don't know what you mean here? Every comparator is required to be
> *reflexive*! Subtracting two pointers to elements of the same array gives
> a perfectly fine total order as far as I see (it is the same as the
> difference between the array indices of those elements).
I meant "anti-commutativity"; sorry about the mixup. Such strategy does not
give a valid total order because the order changes while in-progress sorting
reorders elements:
suppose you have elements A and B such that A precedes B and compare A < B
via address test. At some point, the sort routine may swap A with some
unrelated element C, moving A past B. Now B < A. This is a contradiction.
> In any case, every qsort call that is converted to one with this weaker
> contract will need to be checked. Or we can wait for bug reports ;-)
I think such comparators have a good chance of failing existing qsort_chk
validation.
Alexander
next prev parent reply other threads:[~2018-05-11 12:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 15:57 Alexander Monakov
2018-05-10 15:57 ` [PATCH 2/2] gcc_qsort: build system changes Alexander Monakov
2018-05-11 9:32 ` Richard Biener
2018-05-10 17:01 ` [PATCH 1/2] gcc_qsort: source code changes Alexander Monakov
2018-05-10 17:01 ` David Malcolm
2018-05-10 17:44 ` Richard Biener
2018-05-10 18:08 ` Alexander Monakov
2018-05-10 18:57 ` DJ Delorie
2018-05-11 12:03 ` Richard Biener
2018-05-11 13:12 ` Alexander Monakov
2018-05-13 23:56 ` H.J. Lu
2018-05-14 8:44 ` Alexander Monakov
2018-05-14 9:08 ` Richard Biener
2018-05-10 17:35 ` [PATCH 0/2] Introduce gcc_qsort Jakub Jelinek
2018-05-10 17:48 ` Alexander Monakov
2018-05-10 17:43 ` Richard Biener
2018-05-10 17:57 ` Alexander Monakov
2018-05-11 10:35 ` Segher Boessenkool
2018-05-11 10:44 ` Alexander Monakov
2018-05-11 12:00 ` Segher Boessenkool
2018-05-11 12:16 ` Alexander Monakov [this message]
2018-05-11 12:52 ` Segher Boessenkool
2018-05-11 16:54 ` Eric Botcazou
2018-05-11 11:17 ` Jakub Jelinek
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=alpine.LNX.2.20.13.1805111457000.1437@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
--cc=segher@kernel.crashing.org \
/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).