view gcc/testsuite/g++.dg/cpp1y/pr66443-cxx14.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

// { dg-do run { target c++14 } }

// pr c++/66443 a synthesized ctor of an abstract class that's deleted
// only because of virtual base construction doesn't stop a derived
// class using it as a base object constructor (provided it has a
// suitable ctor invocation of the virtual base).

static int a_made;

struct A {
  A *m_a = this;
  A (int) { a_made++; }
};

struct B : virtual A {
  A *m_b = this;
  virtual bool Ok () = 0; // abstract
};

struct C : B {
  // C::m_c is placed where a complete B object would put A
  int m_c = 1729;
public:
  C();
  virtual bool Ok ();
};

bool C::Ok ()
{
  // check everyone agreed on where A is
  return a_made == 1 && m_a == this && m_b == this && m_c == 1729;
}

C::C ()
  : A (1) // Explicit call of A's ctor
{  }

bool Ok (C &c)
{
  return true;
}

int main ()
{
  C c;

  return !c.Ok ();
}