[orbitcpp-list] [ orbitcpp-Bugs-503269 ] generate skel code not legal C++
Status: Beta
Brought to you by:
philipd
From: <no...@so...> - 2002-01-21 11:43:22
|
Bugs item #503269, was opened at 2002-01-14 03:01 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=100646&aid=503269&group_id=646 Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Richard Andrews (bbmaj7) >Assigned to: Sam Couter (eddiesam) Summary: generate skel code not legal C++ Initial Comment: Let me present an example of what currently occurs. This is a skel generated from the everything test test_VariableLengthStruct * _skel_opVariable( ::PortableServer_Servant _servant, const test_VariableLengthStruct * inArg, test_VariableLengthStruct *inoutArg, test_VariableLengthStruct **outArg, ::CORBA_Environment *_ev) { ::test::VariableLengthStruct *_retval = NULL; bool _results_valid = true; try { POA_test::StructServer * _self = ((_orbitcpp_Servant *)_servant)->m_cppimpl; _retval = _self->opVariable( reinterpret_cast< const VariableLengthStruct&>(*inArg), reinterpret_cast< VariableLengthStruct&>(*inoutArg), reinterpret_cast< VariableLengthStruct*&>(*outArg) ); } I have removed namespace qualifications for clarity. Now what happens here is that _self->opVariable expects a Data_out<VariableLengthStruct> & (non-const ref) as argument 3. Under C++ implied construction rules this is no problem because Data_out<...> has a constructor from VariableLengthStruct*&. BUT... and here's the big problem. This constructor creates a temporary object which is passed as a reference through parameter 3, however only const-references to temporaries may be passed in standard C++ (as is now enforced in gcc3). The only legal way to get around this problem is to construct a wrapper object before the call, then pass this as the non-const reference. Eg. try { POA_test::StructServer * _self = ((_orbitcpp_Servant *)_servant)->m_cppimpl; Data_out< VariableLengthStruct> wrapper3( reinterpret_cast< VariableLengthStruct*&>(*outArg) ); _retval = _self->opVariable( reinterpret_cast< const VariableLengthStruct&>(*inArg), reinterpret_cast< VariableLengthStruct&>(*inoutArg), wrapper3); } In this case because wrapper3 is not a temporary it can be passed through a non-const reference as is required for argument 3 of opVariable(). In general the skeleton code for invoking operations needs to be modified so that for each argument to the servant implementation that is passed by non-const reference, a temporary is constructed and passed. I've been having a look at the code. The main areas of interest are IDLPassSkels::doOperationSkel() IDL_X_X_X_::getCPPSkelParameterTerm() -- I put in a kludge in orbitcpp_smrtptr.hh about a year ago using const_cast<>() to get around this problem but it is no longer sufficient. The problem needs to be fixed at the source which is the generated skel code. I'm willing to put some time into fixing this if someone familiar with this code can help me out. ---------------------------------------------------------------------- >Comment By: Sam Couter (eddiesam) Date: 2002-01-21 03:43 Message: Logged In: YES user_id=14486 Richard's supplied patch has been applied. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=100646&aid=503269&group_id=646 |