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 mi/13393] There is no way to access runtime type of C++variable via MI (using RTTI)


http://sourceware.org/bugzilla/show_bug.cgi?id=13393

--- Comment #13 from Anton <xgsa at yandex dot ru> 2011-11-28 17:17:06 UTC ---
An extended example:


#include <boost/shared_ptr.hpp>

struct Base {
    Base() : a(1) {}
    virtual ~Base() {}  // Enforce type to have RTTI
    int a;
};


struct Derived : public Base {
    Derived() : b(2), c(3) {}
    int b;
    int c;
};


struct S
{
    Base* ptr;
    const Base* ptrConst;
    Base& ref;
    const Base& refConst;

    S(Derived& d)
        :    ptr ( &d )
        ,    ptrConst ( &d )
        ,    ref ( d )
        ,    refConst ( d ) {};
};

int main() {
    Derived d;
    S s(d);
    Base* ptr = &d;
    const Base* ptrConst = &d;
    Base& ref = d;
    const Base& refConst = d;
    Base** ptrToPtr = &ptr;
        // Interesting if pretty printer is used
    boost::shared_ptr<Base> sharedPtr (new Derived());  
    return 0;
}

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]