On Fri, May 11, 2018 at 05:29:05AM -0500, Segher Boessenkool wrote:
> Such a comparator will still work with temporary arrays if both elements
> are always in the same temp array (in deterministic order, etc.) array; but
> it won't work if the comparator did e.g.
> 
>   return (r1 - reload_order) - (r2 - reload_order);
> 
> (it would be undefined behaviour, to start with).

Yeah, UB, but likely would still "work".
What wouldn't work is if a comparator assumes certain sizes of the array
and e.g. stores the difference r1 - reload_order in char/short/int
because all callers guarantee that nmemb * size fits into such types.

        Jakub

Reply via email to