Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: handle case arising from GCC PR 47510
Date: Thu, 03 Feb 2011 08:59:00 -0000	[thread overview]
Message-ID: <20110203085907.GA16851@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <m34o8mf60k.fsf@fleche.redhat.com>

On Wed, 02 Feb 2011 23:03:55 +0100, Tom Tromey wrote:
> Tom> +public:
> Tom> +  C() {}
> Tom> +  ~C() {}
> 
> Jan> If the destructor is not present maybe_smash_one_typedef() will not
> Jan> work.  And GDB crashes now due to it, that should be
> Jan> sanity-protected anyway.
> 
> The class C is not the problem in this test case.  I think C just exists
> to make sure that the "anonymous" struct is not a POD.
> 
> maybe_smash_one_typedef won't be called for C, because C has a name.
> 
> I don't understand about GDB crashing now due to C.

C itself isn't a problem.  But as C no longer has a destructor even `t' no
longer has an implicit destructor.  Due to it maybe_smash_one_typedef gets
called for `t' but it does not do anything as it does not find the '~' field.

Then cp_lookup_nested_type crashes as TYPE_TAG_NAME (parent_type) == NULL
- which is correct for anonymous struct - but cp_lookup_nested_type does not
expect it.


> Jan> I do not fully grok this change, it goes half way.  Why two
> Jan> artificial methods are not non-unique?
> 
> My understanding is that this loop is trying to filter out artificial
> methods in a case like:
> 
>     class K {
>       K(int) { ... }
>     };
> 
> Here, I think, the user can type "ptype K::K" and get "K::K(int)" --
> which makes some kind of sense, ignoring the compiler-generated
> K::K(void).  At least, that is what I think it all means.  I am not sure
> this code is really correct, but this part of the patch is just avoiding
> a crash.
> 
> I don't think it is possible for this loop to see two artificial
> methods.

I thought about:
	class C { public: C() {} };
	class CC { C cf; } cc;
	class D : CC {} d;
	int main () {}
built with:
	GNU C++ 4.4.6 20110124 (prerelease)
producing:
	nm -C file
	00000000004005ac W CC::CC()
	0000000000400592 W CC::CC()
GDB HEAD:
	(gdb) p CC::CC
	Cannot reference virtual member function "CC"
GDB with your patch:
	(gdb) p CC::CC
	$1 = {void (CC * const)} 0x400592 <CC::CC()>
	(that is the 0x4005ac function is not shown to the user)

But this problem is not related to this patch as it happens even with
non-artificial constructors.  lookup_symbol_aux_symtabs just returns the first
matching symbol.  But one cannot specify demangled name for specific kind of
ctor/dtor so lookup_symbol_aux_symtabs must not error on non-unique match.
g++-4.5+ no longer generates multiple kinds of constructors during my tests so
it should not be much a real world concern anymore.

value_struct_elt_for_reference in this case sees only a single CC::CC entry as
the abstract structure itself has only one DIE for CC::CC.

So not an applicable issue for this patch.



Thanks,
Jan


  reply	other threads:[~2011-02-03  8:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 20:21 Tom Tromey
2011-02-02 21:12 ` Jan Kratochvil
2011-02-02 21:47   ` Michael Snyder
2011-02-02 21:50     ` copyright in testcase .cc [Re: RFC: handle case arising from GCC PR 47510] Jan Kratochvil
2011-02-02 21:58       ` Tom Tromey
2011-02-02 22:04   ` RFC: handle case arising from GCC PR 47510 Tom Tromey
2011-02-03  8:59     ` Jan Kratochvil [this message]
2011-02-03 21:07       ` 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=20110203085907.GA16851@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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