File: pr66443-cxx14.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (48 lines) | stat: -rw-r--r-- 841 bytes parent folder | download | duplicates (4)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// { 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 ();
}