Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:09:02+00:00 2026-06-13T00:09:02+00:00

I have an auto_ptr<IFoo> , where IFoo is an interface with just pure-virtual methods.

  • 0

I have an auto_ptr<IFoo>, where IFoo is an interface with just pure-virtual methods.

I now also have a core-file after a segmentation fault, where I’d really like to know what the concrete sub-class was behind this auto_ptr. As dynamic_cast works in the project, I think that RTTI must be available somehow, but I am unaware as how I would access this information via gdb?

The output I get is as follows:

(gdb) print this->obj._M_ptr
$22 = (class martin::IFoo *) 0x7418

What I’d really like to know, if the pointer belongs to an IBaror an IBaz.

Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:09:04+00:00Added an answer on June 13, 2026 at 12:09 am

    What I’d really like to know, if the pointer belongs to an IBaror an IBaz

    GDB should be able to tell you that. Use (gdb) set print object on. Documentation here.

    When displaying a pointer to an object, identify the actual (derived)
    type of the object rather than the declared type, using the virtual
    function table. Note that the virtual function table is required—this
    feature can only work for objects that have run-time type
    identification; a single virtual method in the object’s declared type
    is sufficient.

    Update:

    it only outputs the IFoo* interface

    That likely means that the pointer really is pointing to IFoo (e.g. the object that was of type IBar or IBaz has already been destructed).

    Would working with dynamic_cast imply

    Yes, dynamic_cast can’t work without RTTI; if you are using dynamic_cast, print object on should just work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a auto_ptr I can pass it for a reference?Like: auto_ptr<MyClass>Class(new MyClass);
suppose that,we have following code auto_ptr<T> source() { return auto_ptr<T>( new T(1) ); }
I have a problem with auto_ptr in Exception classes, that I eventually reduced to:
I have been reading up on the c++ auto_ptr and unique_ptr and stuff and
I have class foo that contains a std::auto_ptr member that I would like to
I have a code which looks like this: class Parent { auto_ptr<Resource> ptr2Resc; public:
I have a class like this: class Inner; class Cont { public: Cont(); virtual
I currently have an auto_ptr: auto_ptr<ClassA> classA_; How can I check whether classA_ points
I'm new to C++ and a bit confused regarding auto_ptr. I have a class
perhaps, pointers have been on a course of modification regular pointers to auto_ptr to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.