summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/copy2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/other/copy2.C')
-rw-r--r--gcc/testsuite/g++.dg/other/copy2.C32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/copy2.C b/gcc/testsuite/g++.dg/other/copy2.C
new file mode 100644
index 000000000..335cab8d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/copy2.C
@@ -0,0 +1,32 @@
+// { dg-do run }
+
+// Test that A's copy assignment method is called when B's instance
+// member array of A is assigned.
+
+// Contributed by Brian Gaeke, public domain.
+int status = 1;
+
+class A
+{
+public:
+ int i;
+ A &operator =(const A &i)
+ {
+ status = 0;
+ }
+};
+
+class B
+{
+public:
+ A arr[10];
+};
+
+int main (int argc, char **argv)
+{
+ B b;
+ b.arr[0].i = 15;
+ B a;
+ a = b; // trigger copy assignment
+ return status;
+}