Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: sami wagiaalla <swagiaal@redhat.com>
Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org
Subject: Re: [patch 2/2] Fix overload resolution of int* vs void*
Date: Tue, 12 Oct 2010 20:41:00 -0000	[thread overview]
Message-ID: <m3aamji1pn.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4CB4BE8D.1000001@redhat.com> (sami wagiaalla's message of "Tue,	12 Oct 2010 16:01:17 -0400")

>>>>> "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


  reply	other threads:[~2010-10-12 20:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30 15:24 [patch] " sami wagiaalla
2010-08-30 16:13 ` sami wagiaalla
2010-08-30 20:01 ` Tom Tromey
2010-10-08 18:39   ` [patch 1/2] " sami wagiaalla
2010-10-08 18:54     ` Tom Tromey
2010-10-08 19:35       ` sami wagiaalla
2010-10-08 21:30         ` Tom Tromey
2010-10-08 19:05   ` [patch 2/2] " sami wagiaalla
2010-10-08 20:46     ` Eli Zaretskii
2010-10-08 21:10       ` sami wagiaalla
2010-10-08 22:54         ` Tom Tromey
2010-10-12 20:01           ` sami wagiaalla
2010-10-12 20:41             ` Tom Tromey [this message]
2010-10-13 15:16               ` sami wagiaalla
2010-10-13 15:49                 ` Tom Tromey
2010-10-13 18:29                   ` sami wagiaalla
2010-10-15 14:46                   ` sami wagiaalla
2010-10-15 22:48                     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3aamji1pn.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=swagiaal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox