[review v3] Replace some more qsort calls with std::sort

Christian Biesinger (Code Review) gerrit@gnutoolchain-gerrit.osci.io
Mon Oct 21 16:22:00 GMT 2019


Christian Biesinger has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131
......................................................................


Patch Set 3:

> Patch Set 3:
> 
> It looks like this patch causes some regressions when building with -D_GLIBCXX_DEBUG=1.  One such failure is in gdb.dwarf2/ada-linkage-name.exp (make check TESTS="gdb.dwarf2/ada-linkage-name.exp").
> 
> The problem is that the comparison functions don't have the required properties for std::sort:
> 
>  49 /usr/include/c++/9.2.0/bits/stl_algo.h:4858:^M
>  50 In function:^M
>  51     void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = ^M
>  52     obj_section**; _Compare = bool (*)(const obj_section*, const ^M
>  53     obj_section*)]^M
>  54 ^M
>  55 Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)).^M
>  56 ^M
>  57 Objects involved in the operation:^M
>  58     instance "functor" @ 0x0x7ffda9ccc9a0 {^M
>  59       type = bool (*)(obj_section const*, obj_section const*);^M
>  60     }^M
>  61     iterator::value_type "ordered type" {^M
>  62       type = obj_section*;^M
>  63     }^M
> 
> It is probably a pre-existing bad behavior with the comparison functions, but using std::sort points those out.
> 
> I would encourage you to use -D_GLIBCXX_DEBUG=1 all the time for your development builds (except for when you want to do benchmarks), it catches a bunch of things.

Thanks for finding this! I will make sure to use that define. Meanwhile aburgess uploaded a patch to fix this: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/177




More information about the Gdb-patches mailing list