This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH]: Fix PR tree-optimization/21407


Daniel Berlin wrote:
On Mon, 2005-05-09 at 20:29 -0700, Mark Mitchell wrote:

Daniel Berlin wrote:

On Mon, 2005-05-09 at 22:15 -0400, Daniel Berlin wrote:


Whee.
We pass the address of a derived class to the a call, then upcast it
back to the base class, effectively giving you the structure which
wasn't passed.  You can't do something like this in C, luckily :).

Thus, we can only assume things about address of a structure field when
their is not inheritance involved in the thing we are taking the address
of.
Thus, a TYPE_BINFO check is necessary on the thing whose address if
being taken.

Every class type has TYPE_BINFO. So, you're not really checking for inheritance; you're just checking that it's a class.


So i guess i'm looking for BINFO_N_BASE_BINFOS != 0?

I think that the type itself is considered a base class, so that this will still be 1. But, maybe I'm wrong. I'm also not sure this is consistent across languages. At one point some languages had BINFOs pointing the other way, from base to derived, instead of from derived to base, or at least the documentation suggested that.


(I'm not actually sure what's getting confused here; given that dynamic_cast turns into a function call, I'd think the optimizers would see that like any other call. And if they can eliminate the call, then they must be able to see that the value passed in is a derived class, so I'm not sure why you need to check to see if the class has any base classes.)

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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