Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
OPERATOR_DELETE_PLACEMENT.cpp
Go to the documentation of this file.
1// checking for operator delete (void*, void*)
2
3
25#include "config.h"
26
27#include <stddef.h>
28
29#ifdef _RWSTD_NO_EXCEPTION_SPECIFICATION
30# define throw()
31#endif // _RWSTD_NO_EXCEPTION_SPECIFICATION
32
33
34#ifndef _RWSTD_NO_HONOR_STD
35# ifdef _RWSTD_NO_STD_TERMINATE
36# include "terminate.h"
37# endif // _RWSTD_NO_STD_TERMINATE
38#endif // _RWSTD_NO_HONOR_STD
39
40
41void operator delete (void*, void*) throw ();
42
43void foo (void *p0, void *p1) throw () { ::operator delete (p0, p1); }
44
45void (*operator_delete)(void*, void*);
46
47
49
50struct S {
51 int dummy_;
52
53 ~S () { ++dtor_calls; }
54};
55
56
57int main (int argc, char *argv[])
58{
59 (void)&argv;
60
61 int result = 0;
62
63 char buf [sizeof (S) + 32];
64
65 void *p0 = buf;
66
67 ::operator delete (p0, p0);
68
69 if (0 != dtor_calls)
70 result = (result << 1) + 1;
71
72 if (argc > 1)
73 operator_delete = &operator delete;
74 else
76
77 operator_delete (p0, p0);
78
79 if (0 != dtor_calls)
80 result = (result << 1) + 1;
81
82 // prevent compilers from optimizing the code above away
83 // without actually ever using the result (unless the
84 // test is invoked with command line arguments)
85 if (argc > 1)
86 return result;
87
88 return 0;
89}
#define buf
Definition 17.names.cpp:452
#define p1
Definition 17.names.cpp:239
#define S
Definition 17.names.cpp:162
volatile int result
#define main
void(* operator_delete)(void *, void *)
#define foo(buf, s,...)