aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf/dl5.cc
blob: cc404553f93bf73e4fa209efcb9f378e7e38530a (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <new>

int pass = 0;

void *
operator new (size_t sz, const std::nothrow_t&) throw ()
{
  void *p;
  pass++;
  p = malloc(sz);
  return p;
}

void *
operator new (size_t sz) throw (std::bad_alloc)
{
  void *p;
  pass++;
  p = malloc(sz);
  return p;
}

void
operator delete (void *ptr) throw ()
{
  pass++;
  if (ptr)
    free (ptr);
}

class A 
{
public:
  A() {}
  ~A() { }
  int a;
  int b;
};


int
main (void)
{
  A *bb = new A[10];
  delete [] bb;
  bb = new (std::nothrow) A [10];
  delete [] bb;

  if (pass == 4)
    {
      printf ("PASS\n");
      return 0;
    }
  else
    {
      printf ("FAIL\n");
      return 1;
    }
}