public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "keiths at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/16040] ptype prints the wrong type for members with typedef coming from outside class
Date: Thu, 23 Jan 2014 18:01:00 -0000	[thread overview]
Message-ID: <bug-16040-4717-VeuyYDNT6T@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-16040-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=16040

Keith Seitz <keiths at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |keiths at redhat dot com

--- Comment #1 from Keith Seitz <keiths at redhat dot com> ---
I was playing around a bit today and took a look at what was going on.

This regression was introduced by the following commit:

commit bd69fc683f383772bb8fab43c5d4af8d0cd4a8b4
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 12 17:37:38 2012 +0000

        * c-typeprint.c (find_typedef_for_canonicalize,
        print_name_maybe_canonical): New functions.
        (c_print_type): Look up type name.
[snip]

When c_print_type goes to print `x', it attempts to look up the typedef in the
typedef hash:

  local_name = find_typedef_in_hash (flags, type);

find_typedef_in_hash eventually calls hash_typedef_field, which simply does:

hash_typedef_field (const void *p)
{
  const struct typedef_field *tf = p;
  struct type *t = check_typedef (tf->type);

  return htab_hash_string (TYPE_SAFE_NAME (t));
}

As you can see, it reduces all typedefs to their corresponding fundamental
type. In this case it is `int'. As a result, since the current scope (class c)
defines a typedef for `int' as `another_int', that is what is returned.

Anytime there are multiple typedefs that exist for the same type, this hash
lookup will likely return the wrong typedef name. I used a class which defined
three typedefs for int: int1, int2, int3. As expected, `ptype CLASS' shows all
three typedefs as int1, even though `whatis' shows the proper typedef names for
all three member variables.

[Note about the supplied test case, one must add a reference to another_int in
order for this to demonstrate the failure.]

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  reply	other threads:[~2014-01-23 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-10 23:36 [Bug symtab/16040] New: " dje at google dot com
2014-01-23 18:01 ` keiths at redhat dot com [this message]
2024-01-11 18:24 ` [Bug symtab/16040] " ssbssa at sourceware dot org

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=bug-16040-4717-VeuyYDNT6T@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).