[omniORB] _narrow problems with VAC++ 5.0 on AIX

St. John, Adrian adrian@ipo.att.com
Tue, 1 Aug 2000 09:29:43 -0700


> OK, I've now solved the problem but I am not too sure why it 
> didn't work :-)
> 
> Imagine this scenario:
> 
> Interface A
> Interface B : A
> Interface C : B
> Interface D : C,B
> Interface E : D
> 
> Nice and simple :-) Now consider two implementation classes:
> 
> class B_i : public virtual _sk_B {}
> 
> class E_i : public virtual _sk_E, public virtual B_i {}
> 
> This second declaration is the one causing the problems. An 
> object created of
> type E_i will not work with _narrow correctly. So, if you try 
> to narrow a
> CORBA::Object of type E_i to the correct object reference,
> _widenFromTheMostDerivedIntf will be called as if the object 
> is type A rather
> than type E. To fix this problem, the virtual keywords need 
> to be removed from
> the declaration for E:
> 
> class E_i : public _sk_E, public B_i {}
> 
> I really don't know whether this is a problem with the 
> compiler or not. I am

Its more likely to be a problem with the C++ language.
When deriving from virtual classes in this manner, the
most derived type must specify *ALL* the constructors to be
called in the inheritance list, unless the default constructor
is to be used.

See 'The C++ Programming Language'
In the Special Edition, Section 15.2.4.1 'Programming Virtual Bases'
it gives a full description of what happens.

This is something I came across in a previous life as a competitor
to AT&T Labs in the CORBA area.

Adrian
--
Adrian St. John, ajstjohn@att.com
AT&T Labs, Redditch, UK.