This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16841] New: virtual inheritance via typedef cannot find base


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]