public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "dblaikie at gmail dot com" <sourceware-bugzilla@sourceware.org> 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 [thread overview] Message-ID: <bug-16841-4717@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2014-04-13 16:30 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-13 16:30 dblaikie at gmail dot com [this message] 2014-04-13 16:32 ` [Bug c++/16841] " dblaikie at gmail dot com 2014-04-13 16:33 ` dblaikie at gmail dot com 2014-04-13 16:35 ` dblaikie at gmail dot com 2014-04-24 22:47 ` dblaikie at gmail dot com 2022-10-04 8:22 ` blarsen at redhat dot com
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-16841-4717@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: linkBe 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).