summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/copy2.C
blob: 335cab8d19fef3205de8935fbc874623fce8cc2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}