Discussion:
[omniORB] Union problem in GCC 4.x
Timothy J Brandt
2007-05-18 20:45:59 UTC
Permalink
This was originally noted in July 2005. I wonder if I have missed
something since then.
Below is the orginal description. I still see this in omniORB 4.1.0's
omniidl.

Tim Brandt

When using de the following IDL union def:

module Test
{
typedef long UnionDiscrType;

union TestUnion switch (UnionDiscrType)
{
case -1: short x;
case 1: long y;
};
};

and compiling with g++-4, I get the following errors:

unionDynSK.cc:25: warning: converting negative value '-0x000000001' to
'CORBA::PR_unionDiscriminator'
unionDynSK.cc: In static member function 'static void
_0RL_tcParser_unionhelper_Test_mTestUnion::getDiscriminator(const
omni::tcUnionDesc*, omni::tcDescriptor&,
CORBA::PR_unionDiscriminator&)':
union.hh:195: error: 'CORBA::Long Test::TestUnion::_pd__d' is private
unionDynSK.cc:41: error: within this context
union.hh:195: error: 'CORBA::Long Test::TestUnion::_pd__d' is private
unionDynSK.cc:42: error: within this context
unionDynSK.cc: In static member function 'static void
_0RL_tcParser_unionhelper_Test_mTestUnion::setDiscriminator(const
omni::tcUnionDesc*, CORBA::PR_unionDiscriminator, int)':
union.hh:195: error: 'CORBA::Long Test::TestUnion::_pd__d' is private
unionDynSK.cc:47: error: within this context
union.hh:196: error: 'CORBA::Boolean Test::TestUnion::_pd__default' is
private
unionDynSK.cc:48: error: within this context
unionDynSK.cc: In static member function 'static CORBA::Boolean
_0RL_tcParser_unionhelper_Test_mTestUnion::getValueDesc(const
omni::tcUnionDesc*, omni::tcDescriptor&)':
union.hh:195: error: 'CORBA::Long Test::TestUnion::_pd__d' is private
unionDynSK.cc:53: error: within this context
union.hh:200: error: 'CORBA::Short Test::TestUnion::<anonymous
union>::_pd_x' is private
unionDynSK.cc:55: error: within this context
union.hh:202: error: 'CORBA::Long Test::TestUnion::<anonymous
union>::_pd_y' is private
unionDynSK.cc:58: error: within this context

showing that:

* negative values for union discriminator is converted to unsigned
long (it shouldn't be that way, I'm I right?)
* a friend class declaration is not correct for g++ 4:

#if defined(__GNUG__) || defined(__DECCXX) && (__DECCXX_VER < 60000000)
friend class _0RL_tcParser_unionhelper_Test_mTestUnion;
#else
friend class ::_0RL_tcParser_unionhelper_Test_mTestUnion;
#endif

=> the :: version is necessary for g++ 4

renej
Duncan Grisby
2007-06-19 22:11:14 UTC
Permalink
Post by Timothy J Brandt
This was originally noted in July 2005. I wonder if I have missed
something since then.
Sorry, I've only just had a chance to look at this.

As far as I can see, as well as being reported in July 2005, it was
fixed then as well. omniORB 4.0.7 changes the #ifdef you mention:

[...]
Post by Timothy J Brandt
#if defined(__GNUG__) || defined(__DECCXX) && (__DECCXX_VER < 60000000)
friend class _0RL_tcParser_unionhelper_Test_mTestUnion;
#else
friend class ::_0RL_tcParser_unionhelper_Test_mTestUnion;
#endif
=> the :: version is necessary for g++ 4
The #ifdef now says

#if defined(__GNUG__) && (__GNUG__ < 4) || defined(__DECCXX) && (__DECCXX_VER < 60000000)

I'm also bemused by the fact that you say the issue affects omniORB
4.1.0. That doesn't even have a friend declaration there at all, because
it no longer has the tcParser helper functions.

Can you post some IDL that definitely exhibits a problem, the version of
omniORB it's a problem with, and gcc's output?

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...