summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.pt/spec30.C
blob: c3174d1669810f9a22d2bb9e80fc958fdeffc3dc (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
// { dg-do run  }
#include <cstddef>

template <class T>	
struct S {
  void *operator new (size_t);
  void *operator new (size_t, int);
  void operator delete (void*);
};

static void* s[2];

template <>
void* S<int>::operator new (size_t b) 
{ 
  s[0] = ::operator new(b);
  return s[0];
}

template <>
void* S<int>::operator new (size_t b, int)
{
  s[1] = ::operator new(b);
  return s[1];
}

template <>
void S<int>::operator delete (void*) 
{
}

int main()
{
  S<int>* s1 = new S<int>;
  S<int>* s2 = new(3) S<int>;

  if (s1 != s[0] || s2 != s[1])
    return 1;

  delete s1;
  delete s2;
}