On Tue, 2008-06-03 at 12:10 -0400, Alan Conway wrote:
> ...
> > 
> > I hope that someone could give some solution, otherwise, I will have to 
> > switch to the GNU compiler.
> > 
> 
> Don't do that, make the inheritance public.

No please don't do that

> 
> It's clear from googling around that the issue of dynamic_cast to private 
> bases 
> has confused lots of people, several compiler vendors and the C++ standards 
> comittee. Even if it is technically legal (which I suspect it is not) we 
> should 
> not rely on dynamic_cast to private bases in our code.

We're not doing that at all.

Private inheritance is involved, but the case is simple and not one that
should be a problem.

We start with an AsynchIO (privately inherited from DispatchHandle as
it's not a DispatchHandle it is only implemented in terms of a
DispatchHandle to get the correct lifetime semantics.). The AsynchIO
object is passed as a DispatchHandle to the Dispatcher - this is the
only place where casting through the private inheritance is involved.

This DispatchHandle (which is publically inherited from PollerHandle) is
passed to the Poller as a PollerHandle.

Sometime later the PollerHandle is reconstituted from an epoll_wait and
passed back to the Dispatcher which then needs to cast it to a
DispatchHandle - this is what is failing, as we have a PollerHandle that
we know is a DispatchHandle (as we got it from one) but dynamic_cast
fails.

I can understand that there might be a bug in the dynamic_cast
implementation, but as far as I can tell there should be no failure
here.

I'm wondering now if another cast might succeed.

In any case the use of the private inheritance was an awkward solution,
so if Steve's change holds up I'd gladly change to it (and that will
render this whole issue moot).

Andrew


Reply via email to