Issue 52: Omission in union C++ mapping (cxx_revision) Source: (, ) Nature: Uncategorized Severity: Summary: Summary: Several problems exist with the definition of union constructors. Resolution: fixed by adding clarifying text Revised Text: Actions taken: July 11, 1996: Received issue February 19, 1999: closed issue Discussion: End of Annotations:===== Subject: Omission in union C++ mapping To: cxx_revision@omg.org Date: Thu, 11 Jul 1996 11:46:50 +1000 (EST) Cc: corbanet@dstc.edu.au, trader@dstc.edu.au X-Mailer: ELM [version 2.4 PL25] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1424 Hi, the latest C++ mapping makes it clear that a default-constructed union is in an undefined state, and may not be accessed by the application before setting it. It also states that the copy constructor and assignment operator make a deep copy, but does not make it clear whether it is legal to copy a default-constructed union or assign from a default-constructed union. Further, a union with an implicit default member can be put back into an uninitialized state with the _default() member function. It is not clear whether it is legal to call the copy constructor or assignment operator after calling _default(). Finally, it is not clear whether it is safe to destroy a union that is not initialized, or destroy a union after calling _default(). Suggestion: Calling the copy constructor or assignment operator on an uninitialized union should be required to be safe. The copy will be uninitialized as well. Similarly, copy construction and assignment should be safe after calling _default(), and the copy should be uninitialized. Finally, destroying a default-constructed union should be safe, as should be destruction of a union after calling _default(). 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 >From geoff Thu Jul 11 15:46:23 1996 Received: by amethyst.omg.org (5.4R2.01/1.34) id AA20909; Thu, 11 Jul 1996 15:46:23 -0400 Date: Thu, 11 Jul 1996 15:46:23 -0400 From: geoff (Geoffrey Speare) Message-Id: <9607111946.AA20909@amethyst.omg.org> To: michi@dstc.edu.au Cc: issues, cxx_revision@omg.org, corbanet@dstc.edu.au, trader@dstc.edu.au In-Reply-To: Michi Henning's message of Thu, 11 Jul 1996 11:46:50 +1000 (EST) <199607110146.LAA11927@azure.dstc.edu.au> Subject: Omission in union C++ mapping [Issue 52] This issue has been entered into the OMG revision database as issue #52. > the latest C++ mapping makes it clear that a default-constructed union > is in an undefined state, and may not be accessed by the application > before setting it. > It also states that the copy constructor and assignment operator > make a deep copy, but does not make it clear whether it is legal > to copy a default-constructed union or assign from a > default-constructed > union. > Further, a union with an implicit default member can be put back into > an uninitialized state with the _default() member function. It is not > clear whether it is legal to call the copy constructor or assignment > operator after calling _default(). > Finally, it is not clear whether it is safe to destroy a union that is > not initialized, or destroy a union after calling _default(). > Suggestion: > Calling the copy constructor or assignment operator on > an uninitialized union should be required to be safe. > The copy will be uninitialized as well. > Similarly, copy construction and assignment should be safe > after calling _default(), and the copy should be uninitialized. > Finally, destroying a default-constructed union should be safe, > as should be destruction of a union after calling _default(). > 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 Geoff Speare OMG geoff@omg.org