On Sun, Jul 16, 2017 at 12:38:58PM +0300, Alexander Monakov wrote: > On Sat, 15 Jul 2017, Segher Boessenkool wrote: > > Would it hurt us to use stable sorts *everywhere*? > > Stability (using the usual definition: keeping the original order of > elements that compare equal) is not required to achieve reproducibility [*].
I am well aware, and that is not what I asked. If we would use stable sorts everywhere we would not have to think about whether some sorting routine has to be stable or if we can get away with a (slightly slower) non-stable sort. > [*] nor would it be sufficient, given our current practice of passing > invalid comparators to libc sort, at which point anything can happen > due to undefined behavior That is just a plain bug, undefined behaviour even (C11 7.22.5/4). Of course it needs to be fixed. Segher