URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.eh/] [new1.C] - Rev 841
Go to most recent revision | Compare with Previous | Blame | View Log
// { dg-do run }
// Test that a throw in foo destroys the A, but does not free the memory.
#include <cstddef>
#include <cstdlib>
#include <new>
struct A {
A();
~A();
};
struct B {
B (A);
};
void foo (B*);
int newed, created;
int main ()
{
try {
foo (new B (A ()));
} catch (...) { }
return !(newed && !created);
}
A::A() { created = 1; }
A::~A() { created = 0; }
B::B(A) { }
void foo (B*) { throw 1; }
void* operator new (size_t size) throw (std::bad_alloc)
{
++newed;
return (void *) std::malloc (size);
}
void operator delete (void *p) throw ()
{
--newed;
std::free (p);
}
Go to most recent revision | Compare with Previous | Blame | View Log