summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/inherit/virtual5.C
blob: bed0ef3a07b67b0e4add41d7a6154cc90a379792 (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
// Test that a synthesized op= can override one from a base.
// { dg-do run }

struct B;

struct A
{
  virtual B& operator=(const B&);
};

struct B: A
{
  B(int i): i(i) { }
  int i;
  // implicitly-declared op=
};

B& A::operator=(const B& b) { return static_cast<B&>(*this); }

int main()
{
  B b1 (123);
  B b2 (0);

  A& ar = b1;
  ar = b2;

  return b1.i;
}