view gcc/testsuite/g++.dg/cpp1y/pr66443-cxx14.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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)
{
}

int main ()
{
  C c;

  return !c.Ok ();
}