PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / ubsan / vptr-11.C
blob4516b1e325653b490e1e0da02b6e10fa4fe4b2a1
1 // PR c++/70147
2 // { dg-do run }
3 // { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" }
5 static int ac, ad, bc, bd, cc, cd, dc, dd;
6 struct A
8   A ()
9   {
10     ac++;
11   }
12   virtual void f ()
13   {
14   }
15   __attribute__ ((noinline)) ~ A ();
18 struct D
20   __attribute__ ((noinline)) D (int);
21   ~D ()
22   {
23     dd++;
24   }
26 struct B: virtual A, D
28   B ():D (1)
29   {
30     bc++;
31   }
32   virtual void f ()
33   {
34   }
35   ~B ()
36   {
37     bd++;
38   }
41 struct C: B, virtual A
43   C ()
44   {
45     cc++;
46   }
47   ~C ()
48   {
49     cd++;
50   }
53 D::D (int x)
55   if (x)
56     throw 1;
57   dc++;
60 __attribute__ ((noinline, noclone))
61 void foo (A * p)
63   p->f ();
66 A::~A ()
68   foo (this);
69   ad++;
72 int
73 main ()
75   try
76     {
77       C c;
78     }
79   catch ( ...)
80     {
81     }
82   if (ac != 1 || ad != 1 || bc || bd || cc || cd || dc || dd)
83     __builtin_abort ();