This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Determining type of an object at debug time.


> Finding the vpointer is easy, we always know where it is.

How exactly do you do that? There might not even be a vpointer in the
struct... Consider

struct Base{
  char buf[1000];
  int i;
};

struct Derived:virtual Base{
  virtual ~Derived();
};

Given a Base*, how exactly do you find out that the complete object is
a Derived*? Or, worse, what if it is

void foo(void*x){
 ...
}

foo(new Derived);

How do you know x is a Derived* inside foo?

> I have it working.

Very good!

Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]