Bug 15008 - Lookup of base types with virtual functions is broken
Summary: Lookup of base types with virtual functions is broken
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.5
: P2 normal
Target Milestone: 7.6
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-10 13:20 UTC by Andre'
Modified: 2013-10-31 19:40 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre' 2013-01-10 13:20:09 UTC
In the following code I would expect 'ptype A' to find A, no matter whether foo is declared virtual or not"


    struct A { };
    struct B : A { };
    struct C : B { virtual void foo() { } };
     
    struct D : C
    {
        void foo()
        {
            // Break here.
            // (gdb) ptype A
            // -> Type D has no component named A.
            A *b = 0;
        }
     
        void bar()
        {
            // Break here.
            // (gdb) ptype A
            // -> Type D has no component named A.
            A *b = 0;
        }
    };
     
    int main()
    {
        // Break here.
        // (gdb) ptype A
        // -> type = struct A { ... }
        D d;
        d.foo();
        d.bar();
    }
     
     
    // Note: If the 'virtual' is removed from C::foo(),
    // ptype A works in both D::foo() and D::bar()
Comment 1 Tom Tromey 2013-01-10 14:52:40 UTC
I tried this with today's git master using the Fedora 16 gcc.
It worked fine:

Breakpoint 3, main () at pr.cc:29
29	        D d;
(gdb) ptype A
type = struct A {
}
(gdb) c
Continuing.

Breakpoint 1, D::foo (this=0x7fffffffe400) at pr.cc:12
12	            A *b = 0;
(gdb) ptype A
type = struct A {
}
(gdb) c
Continuing.

Breakpoint 2, D::bar (this=0x7fffffffe400) at pr.cc:20
20	            A *b = 0;
(gdb) ptype A
type = struct A {
}

I also tried 7.5, and it did fail there.

Could you try a newer gdb?
I wonder if this is PR 8888.
Comment 2 Tom Tromey 2013-10-31 19:40:05 UTC
I think it was fixed in 7.6.