public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16841] New: virtual inheritance via typedef cannot find base
@ 2014-04-13 16:30 dblaikie at gmail dot com
  2014-04-13 16:32 ` [Bug c++/16841] " dblaikie at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dblaikie at gmail dot com @ 2014-04-13 16:30 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/16841] virtual inheritance via typedef cannot find base
  2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
@ 2014-04-13 16:32 ` dblaikie at gmail dot com
  2014-04-13 16:33 ` dblaikie at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dblaikie at gmail dot com @ 2014-04-13 16:32 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from David Blaikie <dblaikie at gmail dot com> ---
Created attachment 7551
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7551&action=edit
clang example showing typedef in inheritance

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/16841] virtual inheritance via typedef cannot find base
  2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dblaikie at gmail dot com @ 2014-04-13 16:33 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from David Blaikie <dblaikie at gmail dot com> ---
Oh, and there's GCC bug 60833 to track the fact that GCC doesn't emit the
typedef here.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/16841] virtual inheritance via typedef cannot find base
  2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
  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
  4 siblings, 0 replies; 6+ messages in thread
From: dblaikie at gmail dot com @ 2014-04-13 16:35 UTC (permalink / raw)
  To: gdb-prs

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

David Blaikie <dblaikie at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at google dot com,
                   |                            |echristo at gmail dot com

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/16841] virtual inheritance via typedef cannot find base
  2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: dblaikie at gmail dot com @ 2014-04-24 22:47 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from David Blaikie <dblaikie at gmail dot com> ---
See PR14819 for the original bug/implementation details for this test and
functionality it is testing.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/16841] virtual inheritance via typedef cannot find base
  2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
                   ` (3 preceding siblings ...)
  2014-04-24 22:47 ` dblaikie at gmail dot com
@ 2022-10-04  8:22 ` blarsen at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: blarsen at redhat dot com @ 2022-10-04  8:22 UTC (permalink / raw)
  To: gdb-prs

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

B. Larsen <blarsen at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blarsen at redhat dot com
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from B. Larsen <blarsen at redhat dot com> ---
My newest commit, 2820f08f2331820808ac2f54d8e3619f36ea258b, fixes this issue

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-04  8:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-13 16:30 [Bug c++/16841] New: virtual inheritance via typedef cannot find base dblaikie at gmail dot com
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

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).