From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10571 invoked by alias); 23 Jan 2014 18:01:39 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 10499 invoked by uid 48); 23 Jan 2014 18:01:38 -0000 From: "keiths at redhat dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: keiths at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-q1/txt/msg00118.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=16040 Keith Seitz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |keiths at redhat dot com --- Comment #1 from Keith Seitz --- 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 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.