This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[review v3] Replace some more qsort calls with std::sort
- From: "Simon Marchi (Code Review)" <gerrit at gnutoolchain-gerrit dot osci dot io>
- To: Christian Biesinger <cbiesinger at google dot com>, gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at sourceware dot org>
- Date: Mon, 21 Oct 2019 00:44:59 -0400
- Subject: [review v3] Replace some more qsort calls with std::sort
- Auto-submitted: auto-generated
- References: <gerrit.1571352182000.Ibcddce12a3d07448701e731b7150fa23611d86de@gnutoolchain-gerrit.osci.io>
- Reply-to: simon dot marchi at polymtl dot ca, tromey at sourceware dot org, cbiesinger at google dot com, gdb-patches at sourceware dot org
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131
......................................................................
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.