[omniORB] Bug in generated code for setting union discriminator

Chris Newbold chris.newbold@laurelnetworks.com
Tue, 12 Sep 2000 08:42:24 -0400


I believe that we have found a bug in the generated code for 
setting a union discriminator; we're using omniORB 3.0 with
patches through bug #11. There does not appear to be any
mention of this problem in the 3.0 or 3.0.1 bug lists, so I'm
assuming it hasn't been seen before.

This example is pretty much verbatim from Henning & Vinoski's
description of unions, p.206... Given this IDL:

module foo {

    enum States { one, two, three };

    union StateInfo switch(States) {

    case one:
	string frooby;

    };

};

It should be possible to activate the "default" member of the
union and then explicitly set the discriminator to either "two"
or three:

	StateInfo info;
	info._default();
	info._d(two);

However, the attempt to set the discriminator always results in
a CORBA::BAD_PARAM exception. Looking at the generated code, it's
obvious that no attempt to change the discriminator value will
ever succeed. The unused label also suggests that something is'nt
quite finished here:

    void _d(States _value){
      // illegal to set discriminator before making a member active
      if (!_pd__initialised) throw CORBA::BAD_PARAM(0,
CORBA::COMPLETED_NO);

      if (_value == _pd__d) return; // no change

      fail:
      throw CORBA::BAD_PARAM(0, CORBA::COMPLETED_NO);

    }

-Chris Newbold
Laurel Networks, Inc.