[omniORB] Problem passing an array of structs

Luke Deller ldeller at iress.com.au
Tue May 8 13:41:04 BST 2007

W T Meyer wrote:
> CoRCCClient.cc:92: choosing `T& _CORBA_Array_Fix_Var<T_Helper,
>     T>::operator[](long unsigned int) [with T_Helper =
>     CoRCC::crateInfo_copyHelper, T = CoRCC::crateInfo_slice]' over
> `operator[]'
> CoRCCClient.cc:92:   because worst conversion for the former is better
> than worst conversion for the latter

Are you sure this is an error message?  It looks like a warning to me.
The message says that the compiler is making a choice which is correct.

Quick fix: use (*modList)[i] instead of modList[i] to avoid the warning.

To explain: the expression modList[i] is potentially ambiguous.
modList is of type CoRCC::crateInfo_var, which includes the following
two member functions:

(1)	operator CoRCC::crateInfo_slice * () const;
(2)	CoRCC::crateInfo_slice & operator[] (_CORBA_ULong index_);

So modList can be implicitly converted to a pointer using (1).
The [] operator has been overloaded for this class with (2).

Now modList[i] could mean "implicitly convert modList to a pointer using
(1) and then use the built-in [] operator".  That's what the compiler
would do if the [] operator hadn't been explicitly overloaded.  But
since the [] operator *has* been explicitly overloaded, it will choose
to use (2) instead.   The warning message states that the compiler has
made this choice, which is fine.  In fact either works correctly.

If you use (*modList)[i] then you remove the ambiguity by forcing
modList to be converted to a pointer, so the warning should go away.

Important Note
This email (including any attachments) contains information which is confidential and may be subject to legal privilege.  If you are not the intended recipient you must not use, distribute or copy this email.  If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this email are not necessarily the views of IRESS Market Technology Limited.

It is the duty of the recipient to virus scan and otherwise test the information provided before loading onto any computer system.
IRESS Market Technology Limited does not warrant that the information is free of a virus or any other defect or error.

More information about the omniORB-list mailing list