view gcc/testsuite/g++.dg/inherit/virtual5.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// 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;
}