Manuel Teira wrote:
Andrew Stitcher escribió:
On Tue, 2008-06-03 at 16:51 +0200, Manuel Teira wrote:
Andrew Stitcher escribió:
...
It looks to me like either this is a bug in the Sun compiler or the gcc
one.
As in either the Sun compiler should be able to perform the conversion
even though there is private inheritance is involved. Or the gcc
compiler is allowing a conversion where it shouldn't.
I think this must be true (and I don't think you've shown otherwise).
One behaviour or the other is wrong.
Is there any possibility of using gcc for your compiles?
[Not that I'm trying to put you off the Sun compiler, but if gcc
works...]
Well, I would like to be able to use the Sun Compiler. I also think that
it would be good for the project.
I completely agree that the more compilers you use the higher the code
quality you get in general.
I would like to understand where the problem is. So, please comment on
my (probably wrong) hypothesis:
We have the following inheritance chain:
AsynchIO: private DispatchHandle
DispatchHandle: public PollerHandle
...
Sorry, I can't tell from what you've said here what the hypothesis
actually is.
I think you are saying something about the difference between actual
object types and the types being passed. So that dynamic_cast<> behaves
differently on the two platforms.
Yes, kind of. Sorry for not being more clear. Something weird, like the
*this pointer behaving differente inside DispatchHandle and outside it.
But cannot be materialized in an idea, even.
As a side note, it will be difficult to change this inheritance scheme
as the lifetime of the AsynchIO object is dependant on it being deleted
as a DispatchHandle so aggregation of a DispatchHandle in the AsynchIO
object won't allow this.
Doh!
Well, as a last resort, I've posted the following question in the Sun
Studio C++ forum
http://forum.java.sun.com/thread.jspa?threadID=5301939
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.
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.
Cheers,
Alan.