Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
Cc: Keith Seitz <keiths@redhat.com>,
	GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [RFA] "constify" parse_exp_1
Date: Sat, 09 Mar 2013 01:00:00 -0000	[thread overview]
Message-ID: <513A899C.2030800@redhat.com> (raw)
In-Reply-To: <5139EDDB.8080201@redhat.com>

On 03/08/2013 12:27 PM, Pedro Alves wrote:
> Do we really need it?  Does this:
>
> -	      exp = parse_exp_1 (&p, loc->address,
> +	      exp = parse_exp_1 ((const char **) &p, loc->address,
>
> break strict aliasing rules?

Joseph Meyers confirmed this is indeed not valid in C.

> BTW, over lunch I just had an epiphany.  :-)
> This is perfectly fine:
> 
>  	  for (loc = t->base.loc; loc; loc = loc->next)
>  	    {
> -	      p = tmp_p;
> +	      const char *q;
> +
> +	      q = tmp_p;
> -	      exp = parse_exp_1 (&p, loc->address,
> +	      exp = parse_exp_1 (&q, loc->address,
> 				 block_for_pc (loc->address), 1);
> +	      p = (char *) q;
> 
> It's perfectly valid, as we know Q on output must point within
> the object/string TMP_P pointed at on entry.
> This reads much more intuitively to me, no funny arithmetic, and
> gets rid of the aliasing issue with the other suggestion, and
> no new function necessary.

And confirmed this approach is valid.

-- 
Pedro Alves


  reply	other threads:[~2013-03-09  1:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08  0:12 Keith Seitz
2013-03-08  0:22 ` Pedro Alves
2013-03-08  1:02   ` Keith Seitz
2013-03-08 12:27     ` Pedro Alves
2013-03-08 13:55       ` Pedro Alves
2013-03-09  1:00         ` Pedro Alves [this message]
2013-03-09  1:04           ` Keith Seitz
2013-03-11 22:09             ` Keith Seitz
2013-03-12 10:18               ` Pedro Alves
2013-03-12 17:40                 ` Keith Seitz
2013-03-08 14:54     ` Tom Tromey
2013-03-11 16:50       ` Keith Seitz
2013-03-11 18:30         ` 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=513A899C.2030800@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@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