[review] gdb: Ensure that !(a < a) is true in sort_cmp on obj_section objects

Andrew Burgess (Code Review)
2019-10-21T15:49:39Z

index 6f1a1c0..8dea436 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-10-21 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * objfiles.c (sort_cmp): Ensure that !(a < a) holds true.
+
2019-10-21 Tom Tromey <tom@tromey.com>

* configure.ac (nm.h): Conditionally create nm.h link. Subst
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index fd1cbf7..18a3e98 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1044,19 +1044,23 @@
doesn't happen at all). If you discover that significant time is
spent in the loops below, do 'set complaints 100' and examine the
resulting complaints. */
-
if (objfile1 == objfile2)
{
- /* Both sections came from the same objfile. We are really confused.
- Sort on sequence order of sections within the objfile. */
+ /* Both sections came from the same objfile. We are really
+ confused. Sort on sequence order of sections within the
+ objfile. The order of checks is important here, if we find a
+ match on SECT2 first then either SECT2 is before SECT1, or,
+ SECT2 == SECT1, in both cases we should return false. The
+ second case shouldn't occur during normal use, but std::sort
+ does check that '!(a < a)'. */