public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use value_true in value_equal and value_less
@ 2023-03-27 14:26 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-03-27 14:26 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d784fa8fb2936fb9bd2ebb8e1854b855ca206d96
commit d784fa8fb2936fb9bd2ebb8e1854b855ca206d96
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Mar 1 12:23:43 2023 -0700
Use value_true in value_equal and value_less
Both value_equal and value_less use value_as_long to check a
presumably boolean result of calling value_binop. However,
value_binop in this case actually returns an int as wide as its
arguments, and this approach can then fail for integers wider than
LONGEST. Instead, rewrite this in a form that works for any size
integer.
Diff:
---
gdb/valarith.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/gdb/valarith.c b/gdb/valarith.c
index b3321e4ff75..25d72b7f38c 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1745,8 +1745,7 @@ value_equal (struct value *arg1, struct value *arg2)
is_int2 = is_integral_type (type2);
if (is_int1 && is_int2)
- return longest_to_int (value_as_long (value_binop (arg1, arg2,
- BINOP_EQUAL)));
+ return value_true (value_binop (arg1, arg2, BINOP_EQUAL));
else if ((is_floating_value (arg1) || is_int1)
&& (is_floating_value (arg2) || is_int2))
{
@@ -1833,8 +1832,7 @@ value_less (struct value *arg1, struct value *arg2)
if ((is_int1 && is_int2)
|| (is_fixed_point_type (type1) && is_fixed_point_type (type2)))
- return longest_to_int (value_as_long (value_binop (arg1, arg2,
- BINOP_LESS)));
+ return value_true (value_binop (arg1, arg2, BINOP_LESS));
else if ((is_floating_value (arg1) || is_int1)
&& (is_floating_value (arg2) || is_int2))
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-27 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 14:26 [binutils-gdb] Use value_true in value_equal and value_less Tom Tromey
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).