Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr89698.C

raw
1 /* { dg-do run } */
2
3 extern "C" void abort (void);
4
5 class A {
6 virtual void f(){};
7 public:
8 int x;
9 A(int in): x(in) {};
10 };
11
12 class B: public A {
13 public:
14 int y;
15 B(int in):A(in-1), y(in) {};
16 };
17
18 int test(void)
19 {
20 int res;
21 B b(2);
22 A* bp = &b;
23 void* vp = dynamic_cast<void*>(bp);
24 if (((A*)vp)->x == 1 && ((B*)vp)->y == 2)
25 return 1;
26 return 0;
27 }
28 int main() { if (test() != 1) abort (); return 0; }