From: Aleksandar Ristovski <aristovski@qnx.com>
To: Michael Snyder <msnyder@specifix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] fix for c++/2416
Date: Wed, 27 Feb 2008 19:36:00 -0000 [thread overview]
Message-ID: <47C5BA39.1050306@qnx.com> (raw)
In-Reply-To: <1204137777.19253.418.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]
Michael Snyder wrote:
> On Wed, 2008-02-27 at 13:03 -0500, Aleksandar Ristovski wrote:
>> Hello,
>>
>> As described in the bug report 2416, the problem is with casting to a reference.
>> The attached patch should fix this.
>>
>> Testing on head, no change in pass rate encountered (probably suggesting there
>> is no test case for this - sample code in the bug report should be a good
>> starting point).
>
> I don't understand the change in unpack_long.
> You want to treat structs and unions as longs?
Hmm... I thought I put it there to handle cases when we end up with these type
codes; in that case, I thought, value contains the address and we intepret it as
a long...
However, now I am having trouble reproducing this case, so maybe I had "covered"
this scenario while still searching for a more general solution... in any case,
tests give the same results without unpack_long change and the new diff is attached.
Thanks,
Aleksandar
2008-02-27 Aleksandar Ristovski <aristovski@qnx.com>
* eval.c (evaluate_subexp_standard): UNOP_CAST use
value_cast_pointers when casting reference to reference. Print
error when reference/non-reference mix.
* value.c (value_as_address): Call coerce_array only on arrays.
[-- Attachment #2: casting.diff --]
[-- Type: text/plain, Size: 1698 bytes --]
Index: gdb/eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.80
diff -u -p -r1.80 eval.c
--- gdb/eval.c 4 Feb 2008 00:23:04 -0000 1.80
+++ gdb/eval.c 27 Feb 2008 19:02:41 -0000
@@ -1985,8 +1985,18 @@ evaluate_subexp_standard (struct type *e
arg1 = evaluate_subexp (type, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- if (type != value_type (arg1))
- arg1 = value_cast (type, arg1);
+ if (type != value_type (arg1))
+ {
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_REF
+ && TYPE_CODE (type) == TYPE_CODE_REF)
+ arg1 = value_cast_pointers (type, arg1);
+ else if (TYPE_CODE (value_type (arg1)) != TYPE_CODE_REF
+ && TYPE_CODE (type) != TYPE_CODE_REF)
+ arg1 = value_cast (type, arg1);
+ else /* We can not do much here. */
+ error (_("Attempt to cast to reference type from non-reference "\
+ "type or vice versa."));
+ }
return arg1;
case UNOP_MEMVAL:
Index: gdb/value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.57
diff -u -p -r1.57 value.c
--- gdb/value.c 18 Jan 2008 17:07:40 -0000 1.57
+++ gdb/value.c 27 Feb 2008 19:02:44 -0000
@@ -1039,7 +1039,8 @@ value_as_address (struct value *val)
|| TYPE_CODE (value_type (val)) == TYPE_CODE_METHOD)
return VALUE_ADDRESS (val);
- val = coerce_array (val);
+ if (TYPE_CODE (value_type (val)) == TYPE_CODE_ARRAY)
+ val = coerce_array (val);
/* Some architectures (e.g. Harvard), map instruction and data
addresses onto a single large unified address space. For
next prev parent reply other threads:[~2008-02-27 19:30 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 [this message]
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
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=47C5BA39.1050306@qnx.com \
--to=aristovski@qnx.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@specifix.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