From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14312 invoked by alias); 30 Aug 2010 15:24:49 -0000 Received: (qmail 14301 invoked by uid 22791); 30 Aug 2010 15:24:48 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_DF,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; Mon, 30 Aug 2010 15:24:42 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7UFOeHT001216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Aug 2010 11:24:40 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7UFOefG006974 for ; Mon, 30 Aug 2010 11:24:40 -0400 Received: from [10.15.16.129] (dhcp-10-15-16-129.yyz.redhat.com [10.15.16.129]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o7UFOdev023785 for ; Mon, 30 Aug 2010 11:24:39 -0400 Message-ID: <4C7BCD42.9070308@redhat.com> Date: Mon, 30 Aug 2010 15:24:00 -0000 From: sami wagiaalla User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.2 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [patch] Fix overload resolution of int* vs void* Content-Type: multipart/mixed; boundary="------------040508000400020809010006" 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: 2010-08/txt/msg00520.txt.bz2 This is a multi-part message in MIME format. --------------040508000400020809010006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 186 A fix for this bug http://sourceware.org/bugzilla/show_bug.cgi?id=10343 This patch makes it a little bit cheaper to convert a pointer to void* than any other pointer conversion. Sami --------------040508000400020809010006 Content-Type: text/x-patch; name="overload_voidp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="overload_voidp.patch" Content-length: 4525 Fixed void* vs int* overload issue (PR C++/10343). 2010-08-30 Sami Wagiaalla * gdbtypes.h: Made VOID_PTR_CONVERSION_BADNESS better than INTEGER_PROMOTION_BADNESS. 2010-08-30 Sami Wagiaalla PR C++/10343 * gdb.cp/overload.cc: Added test for void* vs int* overload. * gdb.cp/overload.exp: Ditto. diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 6fc47f2..ed8d613 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1374,25 +1374,25 @@ extern int is_unique_ancestor (struct type *, struct value *); #define INCOMPATIBLE_TYPE_BADNESS 100 /* Badness of integral promotion */ -#define INTEGER_PROMOTION_BADNESS 1 +#define INTEGER_PROMOTION_BADNESS 2 /* Badness of floating promotion */ -#define FLOAT_PROMOTION_BADNESS 1 +#define FLOAT_PROMOTION_BADNESS 2 /* Badness of integral conversion */ -#define INTEGER_CONVERSION_BADNESS 2 +#define INTEGER_CONVERSION_BADNESS 3 /* Badness of floating conversion */ -#define FLOAT_CONVERSION_BADNESS 2 +#define FLOAT_CONVERSION_BADNESS 3 /* Badness of integer<->floating conversions */ -#define INT_FLOAT_CONVERSION_BADNESS 2 +#define INT_FLOAT_CONVERSION_BADNESS 3 /* Badness of converting to a boolean */ -#define BOOLEAN_CONVERSION_BADNESS 2 +#define BOOLEAN_CONVERSION_BADNESS 3 /* Badness of pointer conversion */ -#define POINTER_CONVERSION_BADNESS 2 +#define POINTER_CONVERSION_BADNESS 3 /* Badness of conversion of pointer to void pointer */ -#define VOID_PTR_CONVERSION_BADNESS 2 +#define VOID_PTR_CONVERSION_BADNESS 1 /* Badness of converting derived to base class */ -#define BASE_CONVERSION_BADNESS 2 +#define BASE_CONVERSION_BADNESS 3 /* Badness of converting from non-reference to reference */ -#define REFERENCE_CONVERSION_BADNESS 2 +#define REFERENCE_CONVERSION_BADNESS 3 /* Non-standard conversions allowed by the debugger */ /* Converting a pointer to an int is usually OK */ diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc index 78fae14..dc117fb 100644 --- a/gdb/testsuite/gdb.cp/overload.cc +++ b/gdb/testsuite/gdb.cp/overload.cc @@ -24,6 +24,9 @@ int overload1arg (unsigned long); int overload1arg (float); int overload1arg (double); +int overload1arg (int*); +int overload1arg (void*); + int overloadfnarg (void); int overloadfnarg (int); int overloadfnarg (int, int (*) (int)); @@ -99,6 +102,8 @@ int main () unsigned long arg10 =10; float arg11 =100.0; double arg12 = 200.0; + int arg13 = 200.0; + char arg14 = 'a'; char *str = (char *) "A"; foo foo_instance1(111); @@ -150,6 +155,8 @@ int foo::overload1arg (long arg) { arg = 0; return 9;} int foo::overload1arg (unsigned long arg) { arg = 0; return 10;} int foo::overload1arg (float arg) { arg = 0; return 11;} int foo::overload1arg (double arg) { arg = 0; return 12;} +int foo::overload1arg (int* arg) { arg = 0; return 13;} +int foo::overload1arg (void* arg) { arg = 0; return 14;} /* Test to see that we can explicitly request overloaded functions with function pointers in the prototype. */ diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp index f05cc23..25aeb07 100644 --- a/gdb/testsuite/gdb.cp/overload.exp +++ b/gdb/testsuite/gdb.cp/overload.exp @@ -80,6 +80,8 @@ set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);" set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);" set re_methods "${re_methods}${ws}int overload1arg\\(float\\);" set re_methods "${re_methods}${ws}int overload1arg\\(double\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(int \\*\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(void \\*\\);" set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);" set re_methods "${re_methods}${ws}int overloadfnarg\\(int\\);" set re_methods "${re_methods}${ws}int overloadfnarg\\(int, int ?\\(\\*\\) ?\\(int\\)\\);" @@ -256,6 +258,14 @@ gdb_test "print foo_instance1.overload1arg((double)arg12)" \ "\\$\[0-9\]+ = 12" \ "print call overloaded func double arg" +gdb_test "print foo_instance1.overload1arg(&arg13)" \ + "\\$\[0-9\]+ = 13" \ + "print call overloaded func int\\* arg" + +gdb_test "print foo_instance1.overload1arg(&arg14)" \ + "\\$\[0-9\]+ = 14" \ + "print call overloaded func char\\* arg" + # --- # List overloaded functions. --------------040508000400020809010006--