From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 675 invoked by alias); 27 Feb 2008 19:30:22 -0000 Received: (qmail 665 invoked by uid 22791); 27 Feb 2008 19:30:21 -0000 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO qnxmail.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 27 Feb 2008 19:30:04 +0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.42.96.5]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id OAA10008; Wed, 27 Feb 2008 14:13:15 -0500 Received: from [10.42.100.129] (dhcp-100-129 [10.42.100.129]) by smtp.ott.qnx.com (8.8.8/8.6.12) with ESMTP id OAA02685; Wed, 27 Feb 2008 14:30:01 -0500 Message-ID: <47C5BA39.1050306@qnx.com> Date: Wed, 27 Feb 2008 19:36:00 -0000 From: Aleksandar Ristovski User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Michael Snyder CC: gdb-patches@sourceware.org Subject: Re: [patch] fix for c++/2416 References: <47C5A5EE.6070107@qnx.com> <1204137777.19253.418.camel@localhost.localdomain> In-Reply-To: <1204137777.19253.418.camel@localhost.localdomain> Content-Type: multipart/mixed; boundary="------------000300060605090502000506" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00443.txt.bz2 This is a multi-part message in MIME format. --------------000300060605090502000506 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1234 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 * 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. --------------000300060605090502000506 Content-Type: text/plain; name="casting.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="casting.diff" Content-length: 1698 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 --------------000300060605090502000506--