This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib 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: BUG: qsort reorders elements in already sorted array


On Wed, Jun 04, 2003 at 11:58:13AM -0400, J. Johnston wrote:
> 
> I believe the 7 article case is caused by the fact that the code has if 
> logic for < 7
> and > 7, but not for == 7.
> 
> I am not seeing the extraneous values you are seeing.  This requires 
> further investigation.

I'm sorry but I can't reproduce this anymore.  For some reason I'm
now getting the exact same results as on Mac OS X:

$ ./sort 7
3 1 2 0 4 5 6 
$ ./sort 8
7 1 2 3 4 5 6 0 

Weird.  However, with my patch, qsort works as fine in this border case
as qsort in glibc.  The problem here is not that the order of elements
concidered identical is unspecified, the problem is that it reorders
even though no comparison ever returned a non-0 value.  I'm not sure
if that's supposed to happen.

Corinna

-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com


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