1 // { dg-do assemble } 2 // { dg-prune-output "note" } 3 // { dg-prune-output "deleted" } 4 5 // g++ 1.36.1 bug 900121_02 6 7 // Assignment of structs is defined as memberwise assignment, 8 // however g++ (1.36.2) and Cfront 2.0 differ on the definition 9 // of assignment for unions. 10 11 // (NOTE: Stroustrup now says that assignment of unions which contain either 12 // members or sub-members (base classes are not allowed for unions) which 13 // have non-default assignment operators defined for them will be illegal 14 // in future.) 15 16 // g++ (1.36.2) on the other hand, accepts this program without errors. 17 18 // keywords: unions, operator=, inheritance, members 19 20 struct s0 { 21 22 int i; 23 24 void operator= (s0 & arg) 25 { 26 this->i = arg.i; 27 } 28 }; 29 30 struct s1 { 31 32 double d; 33 34 void operator= (s1 & arg) 35 { 36 this->d = arg.d; 37 } 38 }; 39 40 union u0 { 41 s0 u0_member_0; // { dg-error "" } 42 s1 u0_member_1; // { dg-error "" } 43 }; 44 function()45void function () 46 { 47 u0 u0_object_0; 48 u0 u0_object_1; 49 50 u0_object_0 = u0_object_1; 51 } 52 main()53int main () { return 0; } 54