Unstable build/host qsorts causing differing generated target code

Alexander Monakov amonakov@ispras.ru
Fri Jan 12 21:17:00 GMT 2018


On Fri, 12 Jan 2018, Joseph Myers wrote:
> On Fri, 12 Jan 2018, Alexander Monakov wrote:
> 
> > No. The qsort_chk effort was limited to catching instances where comparators
> > are invalid, i.e. lack anti-commutativity (may indicate A < B < A) or
> > transitivity property (may indicate A < B < C < A). Fixing them doesn't
> > imply making corresponding qsort invocations stable.
> 
> Incidentally, does it detect being invalid because of comparing A != A?  

If A appears twice at different positions in the array yes, otherwise no:
qsort_chk never passes two equal pointers to the comparator. This is
intentional: an earlier effort by Yuri Gribov tried to enforce reflexivity,
but that caught instances where input arrays could not contain identical
items. So under the assumption that qsort would never compare an element to
itself, catching and fixing that wouldn't make a difference in practice -
apart from complicating the comparator.

Alexander



More information about the Gcc mailing list