1// PR c++/15097 2// { dg-do run } 3 4typedef __SIZE_TYPE__ size_t; 5 6extern "C" void * malloc (size_t); 7extern "C" void free (void *); 8extern "C" void abort(void); 9 10void *saved; 11 12void * operator new (size_t size) 13{ 14 void *p = malloc (size); 15 saved = p; 16 return p; 17} 18 19void operator delete (void *p) 20{ 21 if (p != saved) 22 abort (); 23 free (p); 24} 25 26struct B1 27{ 28 virtual ~B1 () throw() {} 29 B1 (){} 30 int x; 31}; 32struct B2 33{ 34 virtual ~B2 () throw() {} 35 B2 (){} 36 int x; 37}; 38struct D : B1, B2 39{ 40 D (){} 41 ~D () throw() {} 42 int y; 43}; 44void f1 (D*); 45void f2 (B2*); 46void f3 (B1*); 47int main (void) 48{ 49 f1 (::new D); 50 f2 (::new D); 51 f3 (::new D); 52} 53void f1 ( D* p) { ::delete p; } 54void f2 (B2* p) { ::delete p; } 55void f3 (B1* p) { ::delete p; } 56