public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: gdb-patches@sources.redhat.com
Cc: gdb@sources.redhat.com, ramana.radhakrishnan@codito.com
Subject: Re: Query regarding expression evaluation.
Date: Thu, 11 Aug 2005 10:10:00 -0000	[thread overview]
Message-ID: <jehddwzsus.fsf@sykes.suse.de> (raw)
In-Reply-To: <1123684979.29036.21.camel@localhost.localdomain> (Ramana Radhakrishnan's message of "Wed, 10 Aug 2005 20:12:59 +0530")

Ramana Radhakrishnan <ramana.radhakrishnan@codito.com> writes:

> Look at PR1978 . The discrepancy is because in valarith.c , GDB takes
> the operation to be unsigned depending only on the operand types. In the
> case described in the PR this seems alright with respect to the C
> standard since the result is implementation dependent. 

Here is a fix:

2005-08-11  Andreas Schwab  <schwab@suse.de>

	PR exp/1978
	* valarith.c (value_binop): Fix result type for the shift
	operators.

--- gdb/valarith.c.~1.41.~	2005-07-07 11:12:12.000000000 +0200
+++ gdb/valarith.c	2005-08-10 18:22:48.000000000 +0200
@@ -883,7 +883,14 @@ value_binop (struct value *arg1, struct 
          Use the signedness of the operand with the greater length.
          If both operands are of equal length, use unsigned operation
          if one of the operands is unsigned.  */
-      if (promoted_len1 > promoted_len2)
+      if (op == BINOP_RSH || op == BINOP_LSH)
+	{
+	  /* In case of the shift operators the type of the result only
+	     depends on the type of the left operand.  */
+	  unsigned_operation = is_unsigned1;
+	  result_len = promoted_len1;
+	}
+      else if (promoted_len1 > promoted_len2)
 	{
 	  unsigned_operation = is_unsigned1;
 	  result_len = promoted_len1;

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  parent reply	other threads:[~2005-08-11 10:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-10 14:49 Ramana Radhakrishnan
2005-08-10 15:44 ` Andreas Schwab
2005-08-11 10:10 ` Andreas Schwab [this message]
2005-08-11 13:21   ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jehddwzsus.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=gdb-patches@sources.redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=ramana.radhakrishnan@codito.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).