| 1 |
// { dg-do run } |
| 2 |
// InterViews (ibuild) requires this to work. |
| 3 |
|
| 4 |
extern "C" void exit(int); |
| 5 |
|
| 6 |
void *old; |
| 7 |
|
| 8 |
class c1 |
| 9 |
{ |
| 10 |
int i; |
| 11 |
public: |
| 12 |
c1 () {} |
| 13 |
}; |
| 14 |
|
| 15 |
class c2 |
| 16 |
{ |
| 17 |
int j; |
| 18 |
public: |
| 19 |
c2 () {} |
| 20 |
}; |
| 21 |
|
| 22 |
class c3 : public c1, public c2 |
| 23 |
{ |
| 24 |
public: |
| 25 |
c3 () |
| 26 |
{ |
| 27 |
old = this; |
| 28 |
// printf("new object c3 at %x\n", (int)this); } |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
c2* f () |
| 33 |
{ |
| 34 |
c2* n = new c3 (); |
| 35 |
// printf ("new object c3 casted to c2 at %x\n", (int)n); |
| 36 |
return n; |
| 37 |
} |
| 38 |
|
| 39 |
int main () |
| 40 |
{ |
| 41 |
c3* o = (c3*)f (); |
| 42 |
// printf("new object c3, upcasted from c2 at %x\n", (int)o); |
| 43 |
// if old and o are not the same, fail the test case. |
| 44 |
if (old != o) |
| 45 |
exit(1); |
| 46 |
return 0; |
| 47 |
} |