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_ARRAY_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_array)(size_t,
void
*);
45
46
47
struct
S
{
48
char
c_
;
49
char
d_
;
50
51
S
():
c_
(
'c'
),
d_
(
'd'
) { }
52
};
53
54
55
int
main
(
int
argc,
char
*argv[])
56
{
57
(void)&argv;
58
59
int
result
= 0;
60
61
char
buf
[
sizeof
(
S
) + 32];
62
63
void
*p0 =
buf
;
64
65
void
*
p1
= ::operator
new
[] (
sizeof
(
S
), p0);
66
67
if
(
p1
!= p0)
68
result
=
result
<< 1 + 1;
69
70
if
(argc > 1)
71
operator_new_array
= &
operator
new
[];
72
else
73
operator_new_array
= &
foo
;
74
75
p1
=
operator_new_array
(
sizeof
(
S
), p0);
76
77
if
(
p1
!= p0)
78
result
= (
result
<< 1) + 1;
79
80
S
*
s
=
new
(p0)
S
[1];
81
82
if
(
p1
!= p0)
83
result
= (
result
<< 1) + 1;
84
85
if
(
s
->c_ !=
'c'
||
s
->d_ !=
'd'
)
86
result
= (
result
<< 1) + 1;
87
88
// prevent compilers from optimizing the code above away
89
// without actually ever using the result (unless the
90
// test is invoked with command line arguments)
91
if
(argc > 1)
92
return
result
;
93
94
return
0;
95
}
buf
#define buf
Definition
17.names.cpp:452
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_array
void *(* operator_new_array)(size_t, void *)
Definition
OPERATOR_NEW_ARRAY_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::c_
char c_
Definition
OPERATOR_NEW_ARRAY_PLACEMENT.cpp:48
S::d_
char d_
Definition
OPERATOR_NEW_ARRAY_PLACEMENT.cpp:49
S::S
S()
Definition
OPERATOR_NEW_ARRAY_PLACEMENT.cpp:51
terminate.h
Generated by
1.9.8