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

Jim Blandy
2002-08-21T17:22:29Z

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.