Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
OPERATOR_NEW_PLACEMENT.cpp
Go to the documentation of this file.
1
// checking for operator new (size_t, 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
40
void
*
operator
new
(size_t,
void
*)
throw
();
41
42
void
*
foo
(
size_t
n
,
void
*
p
)
throw
() { return ::operator
new
(
n
,
p
); }
43
44
void
* (*operator_new)(size_t,
void
*);
45
46
47
struct
S
{
48
char
c_
;
49
char
d_
;
50
51
S
():
c_
(0),
d_
(0) { }
52
53
S
(
char
c
):
c_
(
c
),
d_
(0) { }
54
55
S
(
char
c
,
char
d
):
c_
(
c
),
d_
(
d
) { }
56
};
57
58
59
int
main
(
int
argc,
char
*argv[])
60
{
61
(void)&argv;
62
63
int
result
= 0;
64
65
char
buf
[
sizeof
(
S
) + 32];
66
67
void
*p0 =
buf
;
68
69
void
*
p1
= ::operator
new
(
sizeof
(
S
), p0);
70
71
if
(
p1
!= p0)
72
result
=
result
<< 1 + 1;
73
74
if
(argc > 1)
75
operator_new
= &
operator
new
;
76
else
77
operator_new
= &
foo
;
78
79
p1
=
operator_new
(
sizeof
(
S
), p0);
80
81
if
(
p1
!= p0)
82
result
= (
result
<< 1) + 1;
83
84
S
*
s
=
new
(p0)
S
();
85
86
if
(
p1
!= p0)
87
result
= (
result
<< 1) + 1;
88
89
if
(
s
->c_ !=
'\0'
||
s
->d_ !=
'\0'
)
90
result
= (
result
<< 1) + 1;
91
92
s
=
new
(p0)
S
(
'x'
);
93
94
if
(
s
->c_ !=
'x'
||
s
->d_ !=
'\0'
)
95
result
= (
result
<< 1) + 1;
96
97
s
=
new
(p0)
S
(
'y'
,
'z'
);
98
99
if
(
s
->c_ !=
'c'
||
s
->d_ !=
'z'
)
100
result
= (
result
<< 1) + 1;
101
102
// prevent compilers from optimizing the code above away
103
// without actually ever using the result (unless the
104
// test is invoked with command line arguments)
105
if
(argc > 1)
106
return
result
;
107
108
return
0;
109
}
d
#define d
Definition
17.names.cpp:115
buf
#define buf
Definition
17.names.cpp:452
c
#define c
Definition
17.names.cpp:111
s
#define s
Definition
rw_alg_test.h:221
n
#define n
Definition
17.names.cpp:130
p1
#define p1
Definition
17.names.cpp:239
p
#define p
Definition
17.names.cpp:132
d_
#define d_
Definition
17.names.cpp:175
S
#define S
Definition
17.names.cpp:162
c_
#define c_
Definition
17.names.cpp:174
result
volatile int result
Definition
18.limits.traps.stdcxx-624.cpp:35
main
#define main
Definition
BAD_ALLOC_COPY_CTOR.cpp:32
operator_new
void *(* operator_new)(size_t, void *)
Definition
OPERATOR_NEW_PLACEMENT.cpp:44
foo
#define foo(buf, s,...)
Definition
VA_LIST_FUNC_MACRO.cpp:28
stddef.h
S
Definition
COLLAPSE_TEMPLATE_STATICS.cpp:40
S::S
S(char c, char d)
Definition
OPERATOR_NEW_PLACEMENT.cpp:55
S::S
S(char c)
Definition
OPERATOR_NEW_PLACEMENT.cpp:53
S::S
S()
Definition
OPERATOR_NEW_PLACEMENT.cpp:51
terminate.h
Generated by
1.9.8