summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/rtti/dyncast2.C
blob: 2e4f6159696125084345463924347f0bf5dd380b (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
// PR c++/34364
// { dg-do run }

struct A
{
  virtual ~A () {}
};

struct B : public A
{
  template <typename T> struct C
  {
    static void f (A &a)
    {
      dynamic_cast <B &>(a).g ();
    }
  };

  B () : c (6) {}
  void g () { c++; }
  int c;
};

B b;

int
main (void)
{
  B::C<int>::f (b);
  return b.c != 7;
}