This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: GCC 4.2.1: Stabalizing coalesce_list's qsort


On Wed, Aug 22, 2007 at 10:03:50AM -0400, Andrew MacLeod wrote:
> That about says it all :-)
> 
> Maybe we should fix the bug in the sort or provide our own qsort for
> those targets. I'm not sure we should slow everything down on all
> architectures because an implementation of qsort on that target is
> unstable.
> 
> If you want byte for byte identical results on different architectures,
> I fail to see how you can count on different implementations of a sort.

If you assume that the sort is stable, then the results are the same
on every platform regardless of the implementation.

Almost all efficient qsort implementations are unstable.  We have to
either give qsort a sufficiently precise comparison function -
rendering stability irrelevant - or not use qsort.

Glibc's is unstable too, by the way:

     *Warning:* If two objects compare as equal, their order after
     sorting is unpredictable.  That is to say, the sorting is not
     stable.  This can make a difference when the comparison considers
     only part of the elements.  Two elements with the same sort key
     may differ in other respects.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]