matth@tekred.CNA.TEK.COM (Matthew S. Harcourt) (03/30/89)
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<digit>__O<digit>" (note the "_au<digit>_" 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<digit>" (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... -------------------- /* <<cfront 1.2.1 2/16/87>> */ /* < 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 */ --------------------