qsort(), bsearch(), and rude comparison functions

Felix Lee flee at guardian.cs.psu.edu
Wed Oct 10 07:17:33 AEST 1990


>> 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 at cs.psu.edu



More information about the Comp.std.c mailing list