OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [eh/] [new1.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// 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 
8
 
9
int ret = 1;
10
 
11
void *ptr;
12
void * operator new[] (std::size_t s)
13
#if __cplusplus <= 199711L
14
  throw (std::bad_alloc)
15
#endif
16
{
17
  ptr = operator new (s);
18
  return ptr;
19
}
20
 
21
void operator delete[] (void *p) throw ()
22
{
23
  if (p == ptr)
24
    ret = 0;
25
  operator delete (p);
26
}
27
 
28
struct A
29
{
30
  A() { throw 1; }
31
  ~A() {}
32
};
33
 
34
int
35
main ()
36
{
37
  try
38
    {
39
      A *p = new A[4];
40
    }
41
  catch (...) {}
42
  return ret;
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.