Home | History | Annotate | Download | only in jni
      1 // { dg-do run  }
      2 // Origin: philip_martin (at) ntlworld.com
      3 
      4 #include <new>
      5 
      6 extern "C" void abort();
      7 
      8 bool new_flag = false;
      9 bool delete_flag = false;
     10 
     11 struct X {
     12   X()
     13   {
     14     throw 1;
     15   }
     16   void* operator new ( std::size_t n ) throw ( std::bad_alloc )
     17   {
     18     new_flag = true;
     19     return ::operator new( n );
     20   }
     21   void operator delete( void* p, std::size_t n ) throw()
     22   {
     23     delete_flag = true;
     24     ::operator delete( p );
     25   }
     26 };
     27 
     28 int
     29 main()
     30 {
     31   try
     32     {
     33       X* x = new X; // gcc 3.0 fails to call operator delete when X::X throws
     34     }
     35   catch ( ... )
     36     {
     37     }
     38   if ( ! new_flag || ! delete_flag )
     39     ::abort();
     40 }
     41