Hello Sergey, > The option sorting in argp-help was based on the stability > of sort algorithm, therefore the test failed on systems with > quicksort qsort implementations. It went unnoticed on glibc, > because its qsort uses adaptive algorithm, defaulting to > insertion sort if the number of partitions is smaller than a > predefined value, which happens to be true for the argp tests.
Indeed, with your latest changes, the argp tests pass on: - glibc 2.3.6, IRIX 6.5 (where it failed before) - MacOS X 10.3.9, OSF/1 4.0d (not tested last time). > Use argument addresses to ensure they never compare as equal. However, I think this is not portable. While earlier you were assuming a stable sorting algorithm, you are now assuming an in-place sorting algorithm. If a libc were to implement qsort by use of mergesort (and temporary storage), such a sorting algorithm would pass you two pointers to hol_entrys in different array. Then HOL_ENTRY_PTRCMP's result depends on the temporary storage allocation strategy. To make this portable, I see two options: - Sort an array of 'hol_entry*' instead of an array of 'hol_entry'; then you can be sure the hol_entrys stay in place. Or - Add a field 'array_index' to the hol_entry struct. Fill these fields right before calling qsort. Bruno