Issue 584: Bug in example 4.4.1 (port-rtf) Source: (, ) Nature: Uncategorized Severity: Summary: Summary: There is a bug in example 4.4.1 <example> "mems->length(2)" must be added Resolution: close no change in 2.4 Revised Text: Actions taken: June 13, 1997: received issue June 23, 1998: moved from orb_revision to port-rtf August 12, 1999: closed issue Discussion: End of Annotations:===== Return-Path: Sender: ml@ooc.com Date: Thu, 12 Jun 1997 16:53:23 -0400 From: Marc Laukien Organization: Object-Oriented Concepts, Inc. To: issues@omg.org, orb_revision@omg.org Subject: Two bugs in "Dynamic management of Any values" I think I found two bugs in "Dynamic management of Any values": 2. There is a bug in the example 4.4.1: CORBA::ORB_var orb; CORBA::StructMemberSeq mems(2); CORBA::Any result; long value1; boolean value2; mems[0].name = CORBA::string_dup("member1"); mems[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_long); mems[0].name = CORBA::string_dup("member2"); mems[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_boolean); ... "mems -> length(2)" must be added. So the right version is: CORBA::ORB_var orb; CORBA::StructMemberSeq mems(2); mems -> length(2); CORBA::Any result; long value1; boolean value2; mems[0].name = CORBA::string_dup("member1"); mems[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_long); mems[0].name = CORBA::string_dup("member2"); mems[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_boolean); ... [ From the C++ mapping specification: "Unbounded sequences provide a constructor that allows only the initial value of the maximum length to be set (the "maximum constructor" shown in the example above). This allows applications to control how much buffer space is initially allocated by the sequence. This constructor also sets the length to 0 and the release flag to TRUE." And: "The overloaded subscript operators may not be used to access or modify any element beyond the current sequence length. Before either form of operator[] is used on a sequence, the length of the sequence must first be set using the length(ULong) modifier function, unless the sequence was constructed using the T *data constructor." ] Best regards, Marc -- Marc Laukien Phone: (508) 439 9285 x 245 Object-Oriented Concepts, Inc. FAX: (508) 439 9286 44 Manning Rd. WWW: http://www.ooc.com Billerica, MA 01821 E-Mail: mailto:ml@ooc.com Return-Path: X-Sender: vinoski@karloff.boston.iona.ie Date: Thu, 12 Jun 1997 22:26:25 -0400 To: Marc Laukien From: Steve Vinoski Subject: Re: Two bugs in "Dynamic management of Any values" Cc: issues@omg.org, orb_revision@omg.org At 04:53 PM 6/12/97 -0400, Marc Laukien wrote: >2. There is a bug in the example 4.4.1: > >CORBA::ORB_var orb; >CORBA::StructMemberSeq mems(2); >CORBA::Any result; >long value1; >boolean value2; >mems[0].name = CORBA::string_dup("member1"); >mems[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_long); >mems[0].name = CORBA::string_dup("member2"); >mems[1].type = >CORBA::TypeCode::_duplicate(CORBA::_tc_boolean); > >... > >"mems -> length(2)" must be added. You're correct. Another bug is that the "result" variable should be a CORBA::Any*, not a CORBA::Any. --steve