public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix thinko on common/offset-type.h (compare 'lhs' against 'rhs')
@ 2018-10-25 21:10 Sergio Durigan Junior
  2018-10-26  4:03 ` Kevin Buettner
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Sergio Durigan Junior @ 2018-10-25 21:10 UTC (permalink / raw)
  To: GDB Patches; +Cc: Sergio Durigan Junior

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.

gdb/ChangeLog:
2018-10-25  Sergio Durigan Junior  <sergiodj@redhat.com>

	* 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
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-25  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* common/offset-type.h (DEFINE_OFFSET_REL_OP): Compare 'lhs'
+	against 'rhs', instead of with 'lhs' again.
+
 2018-10-25  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* 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
--- a/gdb/common/offset-type.h
+++ b/gdb/common/offset-type.h
@@ -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));				\
   }
 
 DEFINE_OFFSET_REL_OP(>)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-30  3:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 21:10 [PATCH] Fix thinko on common/offset-type.h (compare 'lhs' against 'rhs') Sergio Durigan Junior
2018-10-26  4:03 ` Kevin Buettner
2018-10-26 16:30   ` Sergio Durigan Junior
2018-10-26 16:08 ` Simon Marchi
2018-10-26 16:29   ` Sergio Durigan Junior
2018-10-26 18:23     ` Simon Marchi
2018-10-29 20:11       ` Pedro Alves
2018-10-29 20:14         ` Pedro Alves
2018-10-29 21:14 ` [PATCH] Remove relational operators from common/offset-type.h Sergio Durigan Junior
2018-10-30  3:17   ` Simon Marchi
2018-10-30  3:49     ` Sergio Durigan Junior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).