This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: RFA: static cast from base class to derived class


Daniel Jacobowitz <drow@mvista.com> writes:
> I've got a question... what does VALUE_ADDRESS mean in this context? 
> If it means what it normally means (ought to mean?), then taking an
> address, subtracting an address, and using it as a pointer doesn't make
> a lot of sense.
> 
> Answering my own question - it's dereferencing a pointer to a struct at
> 0.  So we'll actually get an address relative to zero, which makes
> everything work out.  This looks good to me.

Right --- when casting from a base class to a derived class, we use
search_struct_field to find the offset the base class has in the
derived class by creating an imaginary instance of the derived class
at address zero, finding the base class in that, and then using the
base class subobject's address as the offset of the base class in the
derived class.

I wanted to fix the bug in what we did with that offset; beautifying
the way we produced it wasn't on my agenda.  :)

I'll commit this --- thanks.


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