On Fri, May 11, 2018 at 01:35:00PM +0300, Alexander Monakov wrote: > On Fri, 11 May 2018, Segher Boessenkool wrote: > > For example from reload1.c: > > No, this example is not relevant, because ... > > > static int > > reload_reg_class_lower (const void *r1p, const void *r2p) > > { > > int r1 = *(const short *) r1p, r2 = *(const short *) r2p; > > > > // ... > > > > return r1 - r2; > > this subtracts integers, not pointers.
Oh whoops, I read that too fast. Sorry. > 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). 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 ;-) Segher