summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/expr/cast4.C
blob: e9f529b11c6270b86a67b0cf0d647a927db39f07 (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
// { dg-do run }
// PR c++/22132

extern "C" void abort ();

struct foo {
  int a;
  int b;
};

class Foobar : public foo {
public:
  Foobar() { a = 1; b = 2; }
  virtual ~Foobar() {}
};

Foobar obj;
const Foobar* objPtr = &obj;
foo* f = (foo*)objPtr;

int main () {
  if (f->a != 1 || f->b != 2)
    abort ();
}