repo.or.cz
/
netbsd-mini2440.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
No empty .Rs/.Re
[netbsd-mini2440.git]
/
gnu
/
dist
/
gcc4
/
gcc
/
testsuite
/
g++.dg
/
eh
/
new1.C
blob
4c5c684b5f2163020b8790f067ebcb2fb3e06df2
1
// PR c++/5757
2
// Test that when a constructor throws in a new-expression, we pass the
3
// right pointer to operator delete.
4
5
// { dg-do run }
6
7
#include <new>
8
9
int ret = 1;
10
11
void *ptr;
12
void * operator new[] (size_t s) throw (std::bad_alloc)
13
{
14
ptr = operator new (s);
15
return ptr;
16
}
17
18
void operator delete[] (void *p) throw ()
19
{
20
if (p == ptr)
21
ret = 0;
22
operator delete (p);
23
}
24
25
struct A
26
{
27
A() { throw 1; }
28
~A() {}
29
};
30
31
int
32
main ()
33
{
34
try
35
{
36
A *p = new A[4];
37
}
38
catch (...) {}
39
return ret;
40
}