Issue 721: Bounded strings (cxx_revision) Source: (, ) Nature: Uncategorized Severity: Summary: Summary: The C++ mapping basically ignores bounded strings and maps them to char* What should happen if I assign a string that is too long to a bounded string? No statement is made Resolution: resolved, close issue Revised Text: Actions taken: September 18, 1997: received issue February 19, 1999: closed issue, resolved Discussion: End of Annotations:===== Return-Path: X-Authentication-Warning: foxtail.dstc.edu.au: michi owned process doing -bs Date: Thu, 18 Sep 1997 06:45:40 +1000 (EST) From: Michi Henning To: issues@omg.org, cxx_revision@omg.org, orb_revision@omg.org, port-rtf@omg.org Subject: Bounded strings Hi, the C++ mapping basically ignores bounded strings and maps them to char * (I understand why - bounded strings simply don't fit very well into C++). However, no statement is made about what should happen if I assign a string that is too long to a bounded string. I can see two cases where it matters: 1) Assignment to some IDL type, for example: // IDL typedef string<5> short_string; struct x { short_string s; }; // C++ short_string shorty = "I'm too long"; // ??? x myx; myx.s = CORBA::string_dup("I'm too long"); // ??? What should happen during the assignments? 2) Sending a string over an interface when that string is too long: interface foo { void op(in short_string s); }; // C++ foo_var fv = ...; fv->op("This string is too long"); // ??? In the assignment case, I guess there is nothing much you can do. Truncation during assignment is not an option, because that would require a separate C++ type to be generated for each bounded string (so I can overload operator=() appropriately). In the operation case, a BAD_PARAM exception or silent truncation are possible. I would suggest to update the spec such that: 1) It provides some rationale for why bounded strings have basically no support. 2) Explicitly states what should happen if the length of a bounded string is exceeded during IDL data type manipulations (behavior is implementation-defined). 3) Mandate that BAD_PARAM should be raised when too long a string is passed across an interface. For point (3), the check can typically be implemented in the sender's address space. Because only those interface that actually use bounded strings need to be checked, the run-time cost is minimal. Checking on the sender's side requires dispatch via the stubs or skeleton of course. If I use the DII or DSI, the BAD_PARAM exception can't be raised on the sender's side, because the bound of a string isn't known. This means that the receiver also needs to check, and when using the dynamic interfaces, the BAD_PARAM exception may be raised by the receiver of the string. Again, because only interfaces that actually use bounded strings need to be checked, the run-time overhead for the check is minimal. Cheers, Michi. -- Michi Henning +61 7 33654310 DSTC Pty Ltd +61 7 33654311 (fax) University of Qld 4072 michi@dstc.edu.au AUSTRALIA http://www.dstc.edu.au/BDU/staff/michi-henning.html