This is the mail archive of the gdb-patches@sourceware.org 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: [patch 2/2] Fix overload resolution of int* vs void*


>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> 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


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