On Thu, 2018-05-10 at 18:56 +0300, Alexander Monakov wrote: > * sort.cc: New file. > * system.h [!CHECKING_P] (qsort): Redirect to gcc_qsort. > * vec.c (qsort_chk): Use gcc_qsort.
[...snip...] I'm not a reviewer for this, but there's a lot of fiddly implementation logic here, so maybe this code could use the selftest framework? Maybe, in pseudo-code, something like this: template <typename T> static void test_gcc_sort () { for (creation_strategy in {in-order, backwards}: // and anything else? for (int n = 0; n < some_limit; n++) { make_a_list_of_t (n, creation_strategy) gcc_sort (the_list); assert that the list is sorted; assert that the number of calls to the callback was sane } } void test_gcc_sort_cc () { test_gcc_sort<int, int_comparator> (); test_gcc_sort<long, long_comparator> (); // etc; maybe some custom structs to exercise the deterministic property??? } ...or some such, to quickly get coverage of the various list sizes (which the implementation seems to rely on heavily), in a non-release build. Hope this is constructive Dave