1 // { dg-do run } 2 // prms-id: 5571 3 4 int err = 0; 5 void *vp = 0; 6 7 class ParentOne { 8 public: ParentOne()9 ParentOne() {}; 10 #ifdef MAKE_WORK ~ParentOne()11 virtual ~ParentOne() {}; 12 #endif 13 private: 14 char SomeData[101]; 15 }; 16 17 class ParentTwo { 18 public: ParentTwo()19 ParentTwo() {}; ~ParentTwo()20 virtual ~ParentTwo() {}; 21 private: 22 int MoreData[12]; foo()23 virtual int foo() { return 0; } 24 }; 25 26 struct Child : public ParentOne, public ParentTwo { 27 int ChildsToy; 28 virtual void PrintThis() = 0; 29 }; 30 31 struct Student : public Child { 32 int StudentsBook; PrintThisStudent33 void PrintThis() { 34 if (vp == 0) 35 vp = (void *)this; 36 else 37 { 38 if (vp != (void *)this) 39 ++err; 40 } 41 } LocalPrintThisStudent42 void LocalPrintThis() { 43 if (vp == 0) 44 vp = (void *)this; 45 else 46 { 47 if (vp != (void *)this) 48 ++err; 49 } 50 PrintThis(); 51 } ForcedPrintThisStudent52 void ForcedPrintThis() { 53 if (vp == 0) 54 vp = (void *)this; 55 else 56 { 57 if (vp != (void *)this) 58 ++err; 59 } 60 Student::PrintThis(); 61 } 62 }; 63 main()64int main() { 65 Student o; 66 o.LocalPrintThis(); 67 o.ForcedPrintThis(); 68 Child* pX = &o; 69 pX->PrintThis(); 70 return err; 71 } 72