From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14708 invoked by alias); 12 Oct 2010 20:41:03 -0000 Received: (qmail 14695 invoked by uid 22791); 12 Oct 2010 20:41:02 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Oct 2010 20:40:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9CKetwP027196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Oct 2010 16:40:55 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9CKesqg022277; Tue, 12 Oct 2010 16:40:54 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9CKerGi023586; Tue, 12 Oct 2010 16:40:54 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 76B9C378077; Tue, 12 Oct 2010 14:40:53 -0600 (MDT) From: Tom Tromey To: sami wagiaalla Cc: Eli Zaretskii , gdb-patches@sourceware.org Subject: Re: [patch 2/2] Fix overload resolution of int* vs void* References: <4C7BCD42.9070308@redhat.com> <4CAF6B73.5090800@redhat.com> <8339sgo1jl.fsf@gnu.org> <4CAF889C.1080404@redhat.com> <4CB4BE8D.1000001@redhat.com> Date: Tue, 12 Oct 2010 20:41:00 -0000 In-Reply-To: <4CB4BE8D.1000001@redhat.com> (sami wagiaalla's message of "Tue, 12 Oct 2010 16:01:17 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-10/txt/msg00205.txt.bz2 >>>>> "Sami" == sami wagiaalla writes: Sami> I understood that one could convert 'Class ***' to 'BaseClass ***', Sami> but it turns out that is in correct. I should not have assumed that Sami> without testing, and there is nothing in the spec that should have Sami> made me think so. Since that is the case, the calling function can Sami> just deference the pointers. Is there a test for this? There should be. (I didn't check.) Tom> I am curious why you didn't just give POINTER_CONVERSION_BADNESS a new Tom> value and instead introduced BASE_PTR_CONVERSION_BADNESS. Tom> But then, I also don't understand the existing code that returns Tom> POINTER_CONVERSION_BADNESS... Sami> base pointer conversion (BASE_PTR_CONVERSION_BADNESS) is meant to be a Sami> slightly better option than generic (POINTER_CONVERSION_BADNESS) I still don't understand. I guess POINTER_CONVERSION_BADNESS is used for really bogus operations, like converting an int to a pointer. It seems to be a gdb extension. I'm not sure this is worth supporting. Tom> Also, why specifically is_public_ancestor and not is_ancestor? Sami> You can convert a pointer to B to a pointer to A only if A is an Sami> accessible ancestor of B. GDB generally ignores access protection. It seems like it ought to here as well. Sami> + /* If a and b are both pointers types or both reference types then Sami> + they are equal of the same type iff the objects they refer to are Sami> + of the same type. */ Sami> + if (TYPE_CODE (a) == TYPE_CODE_PTR Sami> + || TYPE_CODE (a) == TYPE_CODE_REF) Sami> + return types_equal (TYPE_TARGET_TYPE (a), Sami> + TYPE_TARGET_TYPE (b)); This recursive call seems a little odd. The existence of a check for the "Class ***" case would help prove that it is ok, though. Tom