From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1651 invoked by alias); 13 Apr 2014 16:30:14 -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 1621 invoked by uid 48); 13 Apr 2014 16:30:13 -0000 From: "dblaikie at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/16841] New: virtual inheritance via typedef cannot find base Date: Sun, 13 Apr 2014 16:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dblaikie at gmail 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: 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-q2/txt/msg00048.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=16841 Bug ID: 16841 Summary: virtual inheritance via typedef cannot find base Product: gdb Version: unknown Status: NEW Severity: normal Priority: P2 Component: c++ Assignee: unassigned at sourceware dot org Reporter: dblaikie at gmail dot com gdb.cp/impl-this.exp run with Clang exposes some issues with GDB's handling of inheritance and typedefs. A simplified repro looks something like this: struct base { int i; }; typedef base tbase; struct derived: virtual tbase { void func() { } }; int main() { derived().func(); } break derived::func (gdb) p i $5 = 0 (gdb) p derived::i Internal error: non-aggregate type to value_struct_elt_for_reference (gdb) p base::i $6 = 4196392 (gdb) p tbase::i $7 = 4196392 (gdb) p derived::base::i No type "base" within class or namespace "derived". (gdb) p derived::tbase::i $8 = 4196392 Ideally, all of those expressions would print out the same value. (even with GCC's output, "p derived::i" prints out garbage (4196392 as well, I think)). Without using the typedef for inheritance, but leaving a use in the file (just declaring a global variable of the typedef type "tbase x;") the following output comes from GDB with either Clang or GCC: (gdb) p i $1 = 0 (gdb) p derived::i $2 = 4196392 (gdb) p base::i $3 = 0 (gdb) p tbase::i $4 = 0 (gdb) p derived::base::i $5 = 0 (gdb) p derived::tbase::i No type "tbase" within class or namespace "derived". If the intent is to match the C++ language rules, all of these expressions should print out the same value. When the virtual inheritance was indirect (introducing a "virt" struct, and having "base" derive virtually from "virt" (and "derived" derive non-virtually from "base")) I got a different failure in many of these expressions: "Cannot access memory at address 0x0" but I'm guessing that's just a different manifestation of the same issue) -- You are receiving this mail because: You are on the CC list for the bug.