There's a similar issue if the compar function throws. qsort() may not be exception safe. I don't know that there is a solution, other than when calling external C functions you're on your own, as has always been the case.