Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC, v2] Fix PR symtab/15391
Date: Tue, 14 May 2013 14:31:00 -0000	[thread overview]
Message-ID: <51924AB0.7070402@redhat.com> (raw)
In-Reply-To: <87hai57jsc.fsf@fleche.redhat.com>

On 05/14/2013 02:50 PM, Tom Tromey wrote:
> +  if (TYPE_LENGTH (value_type (value)) < sizeof (LONGEST))
> +    {
> +      LONGEST nbits = 8 * TYPE_LENGTH (value_type (value));
> +      LONGEST m1 = -1;
> +
> +      if (((byte_offset >> (nbits - 1)) & 1) != 0)
> +	byte_offset |= m1 << nbits;
> +    }

I believe left-shifting a negative number is actually undefined
behavior.  It's more usual/idiomatic to do sign extension like:

LONGEST nbits = 8 * TYPE_LENGTH (value_type (value));
int signbit = 1U << nbits;
byte_offset = (byte_offset ^ signbit) - signbit;

-- 
Pedro Alves


  reply	other threads:[~2013-05-14 14:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 13:50 Tom Tromey
2013-05-14 14:31 ` Pedro Alves [this message]
2013-05-14 14:37   ` Tom Tromey
2013-05-14 14:48     ` Pedro Alves
2013-05-14 17:04       ` Tom Tromey
2013-06-18 18:10         ` Tom Tromey

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=51924AB0.7070402@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.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