[omniORB] Mapping problem?

Gary D. Duzan gdd0@gte.com
Fri, 13 Nov 1998 19:17:22 -0500


   According to CORBA 2.0, 16.3.2, and CORBA 2.1, 18.4.2, attempts to
widen one _var type to a base _var type must generate a compiler error.
However, the fact that we have:

template <class T,class T_Helper>
class _CORBA_ObjRef_Var {

  [ ... ]

  inline operator T* () const { return pd_objref; }

  [ ... ]

};

   and:

template <class T,class T_Helper>
class _CORBA_ObjRef_Member {

  [ ... ]

  inline _CORBA_ObjRef_Member<T,T_Helper> &operator= (T * p);

  [ ... ]

};

means that the following succeeds under AIX/xlC:

---------------------------------------------------------------------------

bugtestidl.idl
--------------
interface A {
  void a_op();
};

interface B : A {
  void b_op();
};

struct C {
  A a_member;
};


bugtest.C
---------
#include "bugtestidl.h"

int main(int argc, char *argv[])
{
  B_var bvar;
  C c;

  c.a_member = bvar;
}

---------------------------------------------------------------------------

   While the spec doesn't explicitly say that this must generate an
error, it certainly would have saved me a lot of time if it had. :-)
I'm thinking that changing the signature of the member assignment
operator to:

  inline _CORBA_ObjRef_Member<T,T_Helper> &operator= (T *& p);

might at least force a warning in this case and might not break too
much existing code. (I haven't had the chance to actually try it,
though.) Does this sound like a good idea? Can anyone think of a better
one to deal with the issue?

					Gary Duzan
					GTE Laboratories