2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.bugs / 900121_02.C
blobcb313667ebd784e70f1c79147166793525e6d3d1
1 // { dg-do assemble  }
2 // g++ 1.36.1 bug 900121_02
4 // Assignment of structs is defined as memberwise assignment,
5 // however g++ (1.36.2) and Cfront 2.0 differ on the definition
6 // of assignment for unions.
8 // (NOTE: Stroustrup now says that assignment of unions which contain either
9 // members or sub-members (base classes are not allowed for unions) which
10 // have non-default assignment operators defined for them will be illegal
11 // in future.)
13 // g++ (1.36.2) on the other hand, accepts this program without errors.
15 // keywords: unions, operator=, inheritance, members
17 struct s0 {
19   int i;
21   void operator= (s0 & arg)
22   {
23     this->i = arg.i;
24   }
27 struct s1 {
29   double d;
31   void operator= (s1 & arg)
32   {
33     this->d = arg.d;
34   }
37 union u0 {
38   s0 u0_member_0;               // { dg-error "" } 
39   s1 u0_member_1;               // { dg-error "" } 
42 void function ()
44   u0 u0_object_0;
45   u0 u0_object_1;
47   u0_object_0 = u0_object_1;
50 int main () { return 0; }