This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] handle integer downsizing correctly in C++ overloading


On Fri, Jan 31, 2003 at 11:57:29AM -0800, David Carlton wrote:
> GDB currently won't let you do narrowing integer conversions when
> calling an overloaded C++ function: compile this,
> 
> int overloadChar(char c)
> {
>   return 29;
> }
> 
> int main()
> {
>   overloadChar(1);
> }
> 
> break on main, and try to print overloadChar(1).
> 
> The problem is that gdbtypes.h defines both INTEGER_COERCION_BADNESS
> and INTEGER_CONVERSION_BADNESS.  The former is unacceptably bad; the
> latter isn't preferred, but isn't acceptable.  And in all (or almost
> all) cases, the type comparison functions use INTEGER_COERCION_BADNESS
> when doing narrowing integer comparisons, when they should use
> INTEGER_CONVERSION_BADNESS.
> 
> In fact, INTEGER_COERCION_BADNESS shouldn't exist: there's no such
> thing as an unacceptably bad integer conversion.  So this patch
> changes all uses of INTEGER_COERCION_BADNESS to refer to
> INTEGER_CONVERSION_BADNESS, deletes INTEGER_COERCION_BADNESS, and also
> deletes FLOAT_COERCION_BADNESS (which is similarly unnecessary but
> which is already correctly unused).  And there's a testsuite patch
> included to catch this as well.
> 
> Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2; OK to commit?

I (still) don't have a copy of the standard; I think I'll see about
getting one this week.  However, your explanation makes sense, and
matches my reading of the conversion code that GCC uses for overload
resolution (gcc/cp/call.c:build_conv and standard_conversion).  This
patch is OK.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]