blob: 0f86fccdc937737ebca7e349839e6c746621fed3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// PR c++/5757
// Test that when a constructor throws in a new-expression, we pass the
// right pointer to operator delete.
// { dg-do run }
#include <new>
int ret = 1;
void *ptr;
void * operator new[] (std::size_t s) throw (std::bad_alloc)
{
ptr = operator new (s);
return ptr;
}
void operator delete[] (void *p) throw ()
{
if (p == ptr)
ret = 0;
operator delete (p);
}
struct A
{
A() { throw 1; }
~A() {}
};
int
main ()
{
try
{
A *p = new A[4];
}
catch (...) {}
return ret;
}
|