diff options
Diffstat (limited to 'gcc-4.8/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C')
-rw-r--r-- | gcc-4.8/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C b/gcc-4.8/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C new file mode 100644 index 000000000..15a6d27f3 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C @@ -0,0 +1,53 @@ +// { dg-do assemble } +// { dg-prune-output "note" } +// { dg-prune-output "deleted" } + +// g++ 1.36.1 bug 900121_02 + +// Assignment of structs is defined as memberwise assignment, +// however g++ (1.36.2) and Cfront 2.0 differ on the definition +// of assignment for unions. + +// (NOTE: Stroustrup now says that assignment of unions which contain either +// members or sub-members (base classes are not allowed for unions) which +// have non-default assignment operators defined for them will be illegal +// in future.) + +// g++ (1.36.2) on the other hand, accepts this program without errors. + +// keywords: unions, operator=, inheritance, members + +struct s0 { + + int i; + + void operator= (s0 & arg) + { + this->i = arg.i; + } +}; + +struct s1 { + + double d; + + void operator= (s1 & arg) + { + this->d = arg.d; + } +}; + +union u0 { + s0 u0_member_0; // { dg-error "" } + s1 u0_member_1; // { dg-error "" } +}; + +void function () +{ + u0 u0_object_0; + u0 u0_object_1; + + u0_object_0 = u0_object_1; +} + +int main () { return 0; } |