summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/virtual8.C
blob: f1ec9ada622e1a1f26619d7f855f8a71de0c8687 (plain)
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
// { dg-do run  }
extern "C" int printf (const char*, ...);

struct A
{
  virtual void f () {
    printf ("%x\n", this);
  }
};

struct B : public A
{
};

struct C : public A
{
};

struct D : virtual public B, public C
{
};

int main ()
{
  D d;

  A* a1 = (A*) (B*) &d;
  A* a2 = (A*) (C*) &d;

  a1->f ();
  a2->f ();
}