Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!tektronix!tekgen!tekred!matth From: matth@tekred.CNA.TEK.COM (Matthew S. Harcourt) Newsgroups: comp.lang.c++ Subject: Locally declared anonymous union bug Message-ID: <3783@tekred.CNA.TEK.COM> Date: 30 Mar 89 05:43:12 GMT Reply-To: matth@tekred.CNA.TEK.COM (Matt Harcourt) Organization: Tektronix, Inc., Beaverton, OR. Lines: 51 I don't recall seeing this in previous postings... It seems that cfront version 1.2.1 incorrectly declares and/or accesses locally declared anonymous unions. The following code segment demonstrates the incorrect behavior. Cfront automatically declares an instance of the locally defined anonymous union with the name "_au__O" (note the "_au_" prefix as with other locally declared variables). However, in the statement which accesses a member of the union, the instance is referenced by the name "_auto__O" (prefixed with "_auto_" the way locally defined variable names were prefixed in previous versions of cfront). C++ Source code... -------------------- void foo() { union { // local anonymous union int y; char z; }; y = 1; // access local anonymous union } -------------------- cfront output... -------------------- /* <> */ /* < foo.c */ char *_new(); char _delete(); char *_vec_new(); char _vec_delete(); char foo () { union _C1 { /* sizeof _C1 == 4 */ int __C1_y ; char __C1_z ; }; union _C1 _au1__O1 ; _auto__O1.__C1_y = 1 ; } ; /* the end */ --------------------