comparison gcc/testsuite/g++.old-deja/g++.pt/spec30.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 // { dg-do run }
2 #include <cstddef>
3
4 template <class T>
5 struct S {
6 void *operator new (size_t);
7 void *operator new (size_t, int);
8 void operator delete (void*);
9 };
10
11 static void* s[2];
12
13 template <>
14 void* S<int>::operator new (size_t b)
15 {
16 s[0] = ::operator new(b);
17 return s[0];
18 }
19
20 template <>
21 void* S<int>::operator new (size_t b, int)
22 {
23 s[1] = ::operator new(b);
24 return s[1];
25 }
26
27 template <>
28 void S<int>::operator delete (void*)
29 {
30 }
31
32 int main()
33 {
34 S<int>* s1 = new S<int>;
35 S<int>* s2 = new(3) S<int>;
36
37 if (s1 != s[0] || s2 != s[1])
38 return 1;
39
40 delete s1;
41 delete s2;
42 }