Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: ken@linux.vnet.ibm.com (Ken Werner)
Cc: gdb-patches@sourceware.org, brobecker@adacore.com (Joel Brobecker)
Subject: Re: [patch] fix pre-/post- in-/decrement
Date: Mon, 04 Oct 2010 13:01:00 -0000	[thread overview]
Message-ID: <201010041301.o94D1QHV032611@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <201010011945.27883.ken@linux.vnet.ibm.com> from "Ken Werner" at Oct 01, 2010 07:45:27 PM

Ken Werner wrote:

> -	  return value_assign (arg1, arg2);
> +	  /* Prevent to return a lvalue.  */
> +	  arg3 = value_assign (arg1, arg2);
> +	  VALUE_LVAL (arg3) = not_lval;
> +	  return arg3;

We want to get away from changing core properties like lval
in values after the fact ...   In any case, hard-coding the
lval to non_lval without any further change can cause problems,
e.g. if the value is lazy.

I think there is a more general issue underlying this particular
change.  You're right that the result of a preincrement should
not be an lvalue.  But the same is true for results of assignment
operators in general.

Note that value_assign is used only to implement such operators
(simple assignment, compound assignment, pre/postfix operators).
Since *all* of them return non-lvalues, it might make sense to
simply change value_assign to return a non-lvalue in the first
place ...


> +	  type = value_type (arg1);
> +	  arg3 = allocate_value (type);
> +
> +	  /* Copy the value to prevent to return a lvalue.  */
> +	  memcpy (value_contents_raw (arg3), value_contents (arg1),
> +		  TYPE_LENGTH (type));

I'd prefer to encapsulate this in a function, e.g. value_non_lval (...)
or a similar name, which returns a version of the value that is non_lval.
This could then address a couple of additional issues:
- if the value is already non_lval, no need to create an extra copy
- it might be better to copy the full contents / enclosing type
  for C++ objects

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2010-10-04 13:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17 12:58 [patch] GNU vector unop support Ken Werner
2010-09-28 16:04 ` Ken Werner
     [not found] ` <20100930185634.GC6213@adacore.com>
2010-10-01 17:45   ` [patch] fix pre-/post- in-/decrement Ken Werner
2010-10-04 13:01     ` Ulrich Weigand [this message]
2010-10-04 19:47       ` Ken Werner
2010-10-04 20:45         ` Daniel Jacobowitz
2010-10-04 21:58           ` Ulrich Weigand
2010-10-04 22:59             ` Daniel Jacobowitz
2010-10-04 23:25               ` Ulrich Weigand
2010-10-05  1:17                 ` Daniel Jacobowitz
2010-10-05 13:28                   ` Ulrich Weigand
2010-10-05 13:42                     ` Daniel Jacobowitz
2010-10-06 18:59                       ` [rfc] Fix value_assign return value (Re: [patch] fix pre-/post- in-/decrement) Ulrich Weigand
2010-10-26 13:42                         ` Daniel Jacobowitz
2010-12-01 16:51                           ` Ulrich Weigand
2010-10-06 20:55                       ` [patch] fix pre-/post- in-/decrement Vladimir Prus
2010-10-07 12:38         ` Ken Werner
2010-10-12 23:00           ` Tom Tromey
2010-10-13  8:45             ` Andreas Schwab
2010-10-13  9:23             ` Ken Werner
2010-10-13 16:07               ` Daniel Jacobowitz
2010-10-13 19:01               ` Tom Tromey
2010-10-19  7:38                 ` Ken Werner
2010-11-02  8:23                   ` Ken Werner
2010-11-02 20:31                   ` Tom Tromey
2010-11-03 13:52                     ` Ken Werner
2010-10-04 20:52   ` [patch] GNU vector unop support Ken Werner
2010-10-06 23:27     ` Joel Brobecker
2010-10-07 16:23       ` Ken Werner
2010-11-03 14:07       ` Ken Werner

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=201010041301.o94D1QHV032611@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ken@linux.vnet.ibm.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