Bug 3942 - Return type of index operator for sequences of object references is incorrect
Summary: Return type of index operator for sequences of object references is incorrect
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: IDL Compiler (show other bugs)
Version: 1.8.3
Hardware: All Windows XP
: P5 normal
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks:
 
Reported: 2010-12-20 19:06 CST by Matthew Waller
Modified: 2023-01-25 11:09 CST (History)
1 user (show)

See Also:


Attachments
Test program which highlights issue (522 bytes, text/plain)
2010-12-20 19:06 CST, Matthew Waller
Details
IDL for test program (130 bytes, text/plain)
2010-12-20 19:07 CST, Matthew Waller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Waller 2010-12-20 19:06:22 CST
Created attachment 1343 [details]
Test program which highlights issue

After porting from a previous version of TAO to this version of TAO (1.8.3) I encountered access violations in instances where I was assinging an object reference to an A_var type from a sequence. This is due to the generated code returning a pointer from the indexing operator.

I've been looking at the CORBA C++ mapping spec (v1.2) with respect to the semantics of the return type of the indexing operator of sequences of object references, especially when used as a r-value.

I think the relevant points in are "4.15 Mapping for Sequence Types" on page 38 where it states:

"For strings, wide strings, and object references, operator[] for a sequence must return a type with the same semantics as the types used for string, wide string, and object reference members of structs and arrays …"

Looking at section "4.12 Mapping for Struct Types", on page 27 it states:
"Assignment between a string, wide string, or object reference member and a corresponding T_var type (String_var, WString_var, or A_var) always results in copying the data..."
Putting these two statements together suggests that the following:
MyInterface_var myInterface = mySequenceOfMyInterface[0];
should result in myInterface having a copy of the sequence element rather than owning it's pointer. Additionally, the spec states that the indexing operator for object references should have the same semantics as struct members. 

I think there's a fair case to be made that TAO isn't complying with the standard as far as the sequence indexing operator is concerned. 

I have attached a small bit of code which highlights this issue.
Comment 1 Matthew Waller 2010-12-20 19:07:05 CST
Created attachment 1344 [details]
IDL for test program
Comment 2 Adam Mitz 2011-03-21 11:31:57 CDT
I've hit this same issue.  Works fine in TAO 1.4a so the 1.5.x sequence re-write looks to be the source of the regression.  I have a minimal test case that I will commit shortly.
Comment 3 Adam Mitz 2011-03-31 13:57:32 CDT
Per private email, Johnny is going to look at this one when he has time.
Comment 4 Johnny Willemsen 2011-11-02 13:38:35 CDT
pool
Comment 5 Johnny Willemsen 2023-01-25 11:09:09 CST
https://github.com/DOCGroup/ACE_TAO/issues/2037