This is the mail archive of the
mailing list for the GDB project.
[PATCH] Fix thinko on common/offset-type.h (compare 'lhs' against 'rhs')
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Thu, 25 Oct 2018 17:10:08 -0400
- Subject: [PATCH] Fix thinko on common/offset-type.h (compare 'lhs' against 'rhs')
While doing something else, I noticed that the OFFSET_TYPE's
"DEFINE_OFFSET_REL_OP" has a thinko: it is comparing 'lhs' against
itself, instead of against 'rhs'. This patch fixes it.
I also found an interesting thing. We have an unittest for
offset-type, and in theory it should have caught this problem, because
it has tests for relational operators. However, the tests
successfully pass, and after some investigation I'm almost sure this
is because these operators are not being properly overloaded. I tried
a few things to make them be used, without success. If someone wants
to give this a try, I'd appreciate.
No regressions introduced.
2018-10-25 Sergio Durigan Junior <firstname.lastname@example.org>
* common/offset-type.h (DEFINE_OFFSET_REL_OP): Compare 'lhs'
against 'rhs', instead of with 'lhs' again.
gdb/ChangeLog | 5 +++++
gdb/common/offset-type.h | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 61dc039d4f..d16c81b3a7 100644
@@ -1,3 +1,8 @@
+2018-10-25 Sergio Durigan Junior <email@example.com>
+ * common/offset-type.h (DEFINE_OFFSET_REL_OP): Compare 'lhs'
+ against 'rhs', instead of with 'lhs' again.
2018-10-25 Andrew Burgess <firstname.lastname@example.org>
* python/py-function.c (convert_values_to_python): Return
diff --git a/gdb/common/offset-type.h b/gdb/common/offset-type.h
index b480b14406..ed59227aa5 100644
@@ -81,7 +81,7 @@
using underlying = typename std::underlying_type<E>::type; \
return (static_cast<underlying> (lhs) \
- OP static_cast<underlying> (lhs)); \
+ OP static_cast<underlying> (rhs)); \