Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!psuvax1!news From: flee@guardian.cs.psu.edu (Felix Lee) Newsgroups: comp.std.c Subject: Re: qsort(), bsearch(), and rude comparison functions Message-ID: Date: 9 Oct 90 21:17:33 GMT References: <1990Oct6.013443.5364@twinsun.com> <1990Oct9.062455.21197@sq.sq.com> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 13 Nntp-Posting-Host: guardian.cs.psu.edu >> While we're on the subject, what happens if the comparison function >> has side effects, benign or otherwise? > Nothing prohibits this. A pathological comparison function might shuffle the array being sorted each time it's called, in which case qsort() may never terminate. Is this prohibited? And I notice that 4.3 BSD's qsort uses static variables. Is the comparison function allowed to call qsort recursively? -- Felix Lee flee@cs.psu.edu