Unstable build/host qsorts causing differing generated target code

Michael Matz matz@suse.de
Mon Jan 22 19:43:00 GMT 2018


Hi,

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?  
> (I don't know if qsort implementations ever do compare an element to 
> itself, but I did once notice in a patch review that a comparator could 
> have compared an element unequal to itself).

Many years ago I ran into a qsort implementation (some Sun one? too long 
ago) where indeed qsort was calling cmp(a,a).  I ran into this case only 
because one of the cmp() implementations didn't return 0 then, and qsort 
was Very Surprised by that :)


Ciao,
Michael.



More information about the Gcc mailing list