BUG: qsort reorders elements in already sorted array
Wed Jun 4 16:42:00 GMT 2003
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.
Red Hat, Inc.
More information about the Newlib