delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/08/13:39:35

Date: Tue, 8 Jun 1999 19:39:11 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199906081739.TAA26227@acp3bf.physik.rwth-aachen.de>
To: djgpp AT delorie DOT com
Subject: Re: Bug report
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B
X-Newsreader: TIN [version 1.2 PL2]
Reply-To: djgpp AT delorie DOT com

In article <002301beb1c6$025023c0$4d806ec3 AT marte> you wrote:
> I think I found a bug in the qsort() function.

No, the bug is in your program, at least as of the program you
posted. You lie about the result of the compare function ('0' means
"equal"), so what makes you think that qsort() will be able to find
out the result that you think should be correct? Mind-reading?

More seriously: qsort is explicitly not guaranteed to not change the
order of already sorted entries in the array, or of entries which
compare as 'zero', as returned by the comparison functon. To quote
from the C Standard, where it defines what qsort() does:

	If two elements compare as equal, their order in the sorted
	array is unspecified.

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019