From: Daniel Jacobowitz <drow@false.org>
To: Aleksandar Ristovski <aristovski@qnx.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] fix for c++/2416
Date: Wed, 27 Feb 2008 23:50:00 -0000 [thread overview]
Message-ID: <20080227220659.GE14556@caradoc.them.org> (raw)
In-Reply-To: <47C5D138.6020909@qnx.com>
On Wed, Feb 27, 2008 at 04:08:08PM -0500, Aleksandar Ristovski wrote:
> I haven't made any changes to coerce_array itself, only made sure we do
> not call it if it's not an array. But I find its implementation somewhat
> confusing: it looks like it can be called with all kinds of TYPE_CODE for
> the arg... if that is correct than the name is misfortunate... and if not,
> then we should determine why is it being called with TYPE_CODE_REF (my
> patch eliminates one place where this is being done).
This arises from the C language standard coercions, more or less.
It is supposed to be called with references, functions, pointers, et
cetera. If you give it an array, it gives you back a pointer to the
first element; the same if you do it with a reference to an array.
> Another thing that confuses me is such a special treatment for references
> to something... in my mind, (talking about C++) we should be able to
> internally treat them as pointers to that something.
No, we try to treat them as the thing referenced-to, not the pointer
doing the referencing. This is to be consistent with the languages
we're evaluating. Expression evaluation and printing goes wrong if
you don't.
> For example, in the fix I provided if you comment out
>
> //if (TYPE_CODE (value_type (val)) == TYPE_CODE_ARRAY)
>
> in value.c:1042 (after applying my patch) it will call, as without the
> patch, coerce_array; then if you follow to coerce_ref you will see that
> after coerce_ref, address is messed up causing printing garbage (no
> surprise since the address is wrong).
value_as_address on a reference is supposed to referenced value as an
address, not the pointer value stored in the reference. It's probably
the caller of value_as_address which is mistaken.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2008-02-27 22:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-27 18:43 Aleksandar Ristovski
2008-02-27 19:30 ` Michael Snyder
2008-02-27 19:36 ` Aleksandar Ristovski
2008-02-27 19:47 ` Daniel Jacobowitz
2008-02-27 20:00 ` Aleksandar Ristovski
2008-02-27 20:09 ` Daniel Jacobowitz
2008-02-27 21:26 ` Aleksandar Ristovski
2008-02-27 23:50 ` Daniel Jacobowitz [this message]
2008-02-28 19:12 ` Aleksandar Ristovski
2008-02-28 19:39 ` Daniel Jacobowitz
2008-02-29 10:10 ` Aleksandar Ristovski
2008-03-04 19:39 ` Aleksandar Ristovski
2008-04-01 14:51 ` Daniel Jacobowitz
2008-02-29 2:44 ` Michael Snyder
2008-03-31 19:01 Aleksandar Ristovski
2008-04-01 16:26 Aleksandar Ristovski
2008-04-01 17:06 ` Daniel Jacobowitz
2008-04-01 18:10 Aleksandar Ristovski
2008-04-01 18:52 ` 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=20080227220659.GE14556@caradoc.them.org \
--to=drow@false.org \
--cc=aristovski@qnx.com \
--cc=gdb-patches@sourceware.org \
/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