Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
OPERATOR_DELETE_ARRAY_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#ifndef _RWSTD_NO_HONOR_STD
34# ifdef _RWSTD_NO_STD_TERMINATE
35# include "terminate.h"
36# endif // _RWSTD_NO_STD_TERMINATE
37#endif // _RWSTD_NO_HONOR_STD
38
39
40void operator delete[] (void*, void*) throw ();
41
42void foo (void *p0, void *p1) throw () { ::operator delete[] (p0, p1); }
43
44void (*op_delete_array)(void*, void*);
45
46
48
49struct S {
50 int dummy_;
51
52 ~S () { ++dtor_calls; }
53};
54
55
56int main (int argc, char *argv[])
57{
58 (void)&argv;
59
60 int result = 0;
61
62 char buf [sizeof (S) + 32];
63
64 void *p0 = buf;
65
66 ::operator delete[] (p0, p0);
67
68 if (0 != dtor_calls)
69 result = (result << 1) + 1;
70
71 if (argc > 1)
72 op_delete_array = &operator delete[];
73 else
75
76 op_delete_array (p0, p0);
77
78 if (0 != dtor_calls)
79 result = (result << 1) + 1;
80
81 // prevent compilers from optimizing the code above away
82 // without actually ever using the result (unless the
83 // test is invoked with command line arguments)
84 if (argc > 1)
85 return result;
86
87 return 0;
88}
#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(* op_delete_array)(void *, void *)
#define foo(buf, s,...)