From Jason Turner

[support.dynamic]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1viqj2c_/{from.md → to.md} +117 -28
tmp/tmp1viqj2c_/{from.md → to.md} RENAMED
@@ -17,14 +17,20 @@ namespace std {
17
 
18
  void* operator new(std::size_t size);
19
  void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
20
  void operator delete(void* ptr) noexcept;
21
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
 
 
 
22
  void* operator new[](std::size_t size);
23
  void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
24
  void operator delete[](void* ptr) noexcept;
25
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
 
 
 
26
 
27
  void* operator new (std::size_t size, void* ptr) noexcept;
28
  void* operator new[](std::size_t size, void* ptr) noexcept;
29
  void operator delete (void* ptr, void*) noexcept;
30
  void operator delete[](void* ptr, void*) noexcept;
@@ -95,24 +101,31 @@ is binding on a replacement version of this function.
95
  normally, returns the result of that call. Otherwise, returns a null
96
  pointer.
97
 
98
  ``` cpp
99
  T* p1 = new T; // throws bad_alloc if it fails
100
- T* p2 = new(nothrow) T; // returns 0 if it fails
101
  ```
102
 
103
  ``` cpp
104
  void operator delete(void* ptr) noexcept;
 
105
  ```
106
 
107
  *Effects:* The *deallocation
108
  function* ([[basic.stc.dynamic.deallocation]]) called by a
109
  *delete-expression* to render the value of `ptr` invalid.
110
 
111
- *Replaceable:* a C++program may define a function with this function
112
- signature that displaces the default version defined by the C++standard
113
- library.
 
 
 
 
 
 
114
 
115
  *Requires:* *ptr* shall be a null pointer or its value shall be a value
116
  returned by an earlier call to the (possibly replaced)
117
  `operator new(std::size_t)` or
118
  `operator new(std::size_t,const std::nothrow_t&)` which has not been
@@ -120,37 +133,75 @@ invalidated by an intervening call to `operator delete(void*)`.
120
 
121
  *Requires:* If an implementation has strict pointer
122
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
123
  safely-derived pointer.
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  *Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
126
  the storage allocated by the earlier call to `operator new`.
127
 
128
  *Remarks:* It is unspecified under what conditions part or all of such
129
  reclaimed storage will be allocated by subsequent calls to
130
  `operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
131
  `<cstdlib>`.
132
 
133
  ``` cpp
134
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
 
135
  ```
136
 
137
  *Effects:* The *deallocation
138
  function* ([[basic.stc.dynamic.deallocation]]) called by the
139
  implementation to render the value of `ptr` invalid when the constructor
140
  invoked from a nothrow placement version of the *new-expression* throws
141
  an exception.
142
 
143
- *Replaceable:* a C++program may define a function with this function
144
- signature that displaces the default version defined by the C++standard
145
- library.
 
 
 
 
 
 
 
146
 
147
  *Requires:* If an implementation has strict pointer
148
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
149
  safely-derived pointer.
150
 
151
- *Default behavior:* calls `operator delete(ptr)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
154
 
155
  ``` cpp
156
  void* operator new[](std::size_t size);
@@ -190,50 +241,92 @@ requirement is binding on a replacement version of this function.
190
  normally, returns the result of that call. Otherwise, returns a null
191
  pointer.
192
 
193
  ``` cpp
194
  void operator delete[](void* ptr) noexcept;
 
195
  ```
196
 
197
  *Effects:* The *deallocation
198
  function* ([[basic.stc.dynamic.deallocation]]) called by the array form
199
  of a *delete-expression* to render the value of `ptr` invalid.
200
 
201
- *Replaceable:* a C++program can define a function with this function
202
- signature that displaces the default version defined by the C++standard
203
- library.
 
 
 
 
 
 
204
 
205
  *Requires:* *ptr* shall be a null pointer or its value shall be the
206
  value returned by an earlier call to `operator new[](std::size_t)` or
207
  `operator new[](std::size_t,const std::nothrow_t&)` which has not been
208
  invalidated by an intervening call to `operator delete[](void*)`.
209
 
 
 
 
 
 
 
 
 
 
 
210
  *Requires:* If an implementation has strict pointer
211
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
212
  safely-derived pointer.
213
 
214
- *Default behavior:* Calls `operator delete(ptr)`.
 
 
215
 
216
  ``` cpp
217
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
 
218
  ```
219
 
220
  *Effects:* The *deallocation
221
  function* ([[basic.stc.dynamic.deallocation]]) called by the
222
  implementation to render the value of `ptr` invalid when the constructor
223
  invoked from a nothrow placement version of the array *new-expression*
224
  throws an exception.
225
 
226
- *Replaceable:* a C++program may define a function with this function
227
- signature that displaces the default version defined by the C++standard
228
- library.
 
 
 
 
 
 
 
229
 
230
  *Requires:* If an implementation has strict pointer
231
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
232
  safely-derived pointer.
233
 
234
- *Default behavior:* calls `operator delete[](ptr)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  #### Placement forms <a id="new.delete.placement">[[new.delete.placement]]</a>
237
 
238
  These functions are reserved, a C++program may not define functions that
239
  displace the versions in the Standard C++library ([[constraints]]). The
@@ -294,22 +387,18 @@ operator new terminates by throwing an exception ([[expr.new]]).
294
 
295
  #### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
296
 
297
  For purposes of determining the existence of data races, the library
298
  versions of `operator new`, user replacement versions of global
299
- `operator new`, and the C standard library functions `calloc` and
300
- `malloc` shall behave as though they accessed and modified only the
301
- storage referenced by the return value. The library versions of
302
- `operator delete`, user replacement versions of `operator delete`, and
303
- the C standard library function `free` shall behave as though they
304
- accessed and modified only the storage referenced by their first
305
- argument. The C standard library function `realloc` shall behave as
306
- though it accessed and modified only the storage referenced by its first
307
- argument and by its return value. Calls to these functions that allocate
308
- or deallocate a particular unit of storage shall occur in a single total
309
- order, and each such deallocation call shall happen before the next
310
- allocation (if any) in this order.
311
 
312
  ### Storage allocation errors <a id="alloc.errors">[[alloc.errors]]</a>
313
 
314
  #### Class `bad_alloc` <a id="bad.alloc">[[bad.alloc]]</a>
315
 
 
17
 
18
  void* operator new(std::size_t size);
19
  void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
20
  void operator delete(void* ptr) noexcept;
21
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
22
+ void operator delete(void* ptr, std::size_t size) noexcept;
23
+ void operator delete(void* ptr, std::size_t size,
24
+ const std::nothrow_t&) noexcept;
25
  void* operator new[](std::size_t size);
26
  void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
27
  void operator delete[](void* ptr) noexcept;
28
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
29
+ void operator delete[](void* ptr, std::size_t size) noexcept;
30
+ void operator delete[](void* ptr, std::size_t size,
31
+ const std::nothrow_t&) noexcept;
32
 
33
  void* operator new (std::size_t size, void* ptr) noexcept;
34
  void* operator new[](std::size_t size, void* ptr) noexcept;
35
  void operator delete (void* ptr, void*) noexcept;
36
  void operator delete[](void* ptr, void*) noexcept;
 
101
  normally, returns the result of that call. Otherwise, returns a null
102
  pointer.
103
 
104
  ``` cpp
105
  T* p1 = new T; // throws bad_alloc if it fails
106
+ T* p2 = new(nothrow) T; // returns nullptr if it fails
107
  ```
108
 
109
  ``` cpp
110
  void operator delete(void* ptr) noexcept;
111
+ void operator delete(void* ptr, std::size_t size) noexcept;
112
  ```
113
 
114
  *Effects:* The *deallocation
115
  function* ([[basic.stc.dynamic.deallocation]]) called by a
116
  *delete-expression* to render the value of `ptr` invalid.
117
 
118
+ *Replaceable:* a C++program may define a function with signature
119
+ `void operator delete(void* ptr) noexcept` that displaces the default
120
+ version defined by the C++standard library. If this function (without
121
+ `size` parameter) is defined, the program should also define
122
+ `void operator delete(void* ptr, std::size_t size) noexcept`. If this
123
+ function with `size` parameter is defined, the program shall also define
124
+ the version without the `size` parameter. The default behavior below may
125
+ change in the future, which will require replacing both deallocation
126
+ functions when replacing the allocation function.
127
 
128
  *Requires:* *ptr* shall be a null pointer or its value shall be a value
129
  returned by an earlier call to the (possibly replaced)
130
  `operator new(std::size_t)` or
131
  `operator new(std::size_t,const std::nothrow_t&)` which has not been
 
133
 
134
  *Requires:* If an implementation has strict pointer
135
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
136
  safely-derived pointer.
137
 
138
+ *Requires:* If present, the `std::size_t size` argument shall equal the
139
+ size argument passed to the allocation function that returned `ptr`.
140
+
141
+ *Required behavior:* Calls to
142
+ `operator delete(void* ptr, std::size_t size)` may be changed to calls
143
+ to `operator delete(void* ptr)` without affecting memory allocation. A
144
+ conforming implementation is for
145
+ `operator delete(void* ptr, std::size_t size)` to simply call
146
+ `operator delete(ptr)`.
147
+
148
+ *Default behavior:* the function
149
+ `operator delete(void* ptr, std::size_t size)` calls
150
+ `operator delete(ptr)`. See the note in the above *Replaceable*
151
+ paragraph.
152
+
153
  *Default behavior:* If `ptr` is null, does nothing. Otherwise, reclaims
154
  the storage allocated by the earlier call to `operator new`.
155
 
156
  *Remarks:* It is unspecified under what conditions part or all of such
157
  reclaimed storage will be allocated by subsequent calls to
158
  `operator new` or any of `calloc`, `malloc`, or `realloc`, declared in
159
  `<cstdlib>`.
160
 
161
  ``` cpp
162
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
163
+ void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept;
164
  ```
165
 
166
  *Effects:* The *deallocation
167
  function* ([[basic.stc.dynamic.deallocation]]) called by the
168
  implementation to render the value of `ptr` invalid when the constructor
169
  invoked from a nothrow placement version of the *new-expression* throws
170
  an exception.
171
 
172
+ *Replaceable:* a C++program may define a function with signature
173
+ `void operator delete(void* ptr, const std::nothrow_t&) noexcept` that
174
+ displaces the default version defined by the C++standard library. If
175
+ this function (without `size` parameter) is defined, the program should
176
+ also define
177
+ `void operator delete(void* ptr, std::size_t size, const std::nothrow_t&) noexcept`.
178
+ If this function with `size` parameter is defined, the program shall
179
+ also define the version without the `size` parameter. The default
180
+ behavior below may change in the future, which will require replacing
181
+ both deallocation functions when replacing the allocation function.
182
 
183
  *Requires:* If an implementation has strict pointer
184
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
185
  safely-derived pointer.
186
 
187
+ *Requires:* If present, the `std::size_t size` argument must equal the
188
+ size argument passed to the allocation function that returned `ptr`.
189
+
190
+ *Required behavior:* Calls to
191
+ `operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
192
+ may be changed to calls to
193
+ `operator delete(void* ptr, const std::nothrow_t&)` without affecting
194
+ memory allocation. A conforming implementation is for
195
+ `operator delete(void* ptr, std::size_t size, const std::nothrow_t&)` to
196
+ simply call `operator delete(void* ptr, const std::nothrow_t&)`.
197
+
198
+ *Default behavior:*
199
+ `operator delete(void* ptr, std::size_t size, const std::nothrow_t&)`
200
+ calls `operator delete(ptr, std::nothrow)`, and
201
+ `operator delete(void* ptr, const std::nothrow_t&)` calls
202
+ `operator delete(ptr)`.
203
 
204
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
205
 
206
  ``` cpp
207
  void* operator new[](std::size_t size);
 
241
  normally, returns the result of that call. Otherwise, returns a null
242
  pointer.
243
 
244
  ``` cpp
245
  void operator delete[](void* ptr) noexcept;
246
+ void operator delete[](void* ptr, std::size_t size) noexcept;
247
  ```
248
 
249
  *Effects:* The *deallocation
250
  function* ([[basic.stc.dynamic.deallocation]]) called by the array form
251
  of a *delete-expression* to render the value of `ptr` invalid.
252
 
253
+ *Replaceable:* a C++program can define a function with signature
254
+ `void operator delete[](void* ptr) noexcept` that displaces the default
255
+ version defined by the C++standard library. If this function (without
256
+ `size` parameter) is defined, the program should also define
257
+ `void operator delete[](void* ptr, std::size_t size) noexcept`. If this
258
+ function with `size` parameter is defined, the program shall also define
259
+ the version without the `size` parameter. The default behavior below may
260
+ change in the future, which will require replacing both deallocation
261
+ functions when replacing the allocation function.
262
 
263
  *Requires:* *ptr* shall be a null pointer or its value shall be the
264
  value returned by an earlier call to `operator new[](std::size_t)` or
265
  `operator new[](std::size_t,const std::nothrow_t&)` which has not been
266
  invalidated by an intervening call to `operator delete[](void*)`.
267
 
268
+ *Requires:* If present, the `std::size_t size` argument must equal the
269
+ size argument passed to the allocation function that returned `ptr`.
270
+
271
+ *Required behavior:* Calls to
272
+ `operator delete[](void* ptr, std::size_t size)` may be changed to calls
273
+ to `operator delete[](void* ptr)` without affecting memory allocation. A
274
+ conforming implementation is for
275
+ `operator delete[](void* ptr, std::size_t size)` to simply call
276
+ `operator delete[](void* ptr)`.
277
+
278
  *Requires:* If an implementation has strict pointer
279
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
280
  safely-derived pointer.
281
 
282
+ *Default behavior:* `operator delete[](void* ptr, std::size_t size)`
283
+ calls `operator delete[](ptr)`, and `operator delete[](void* ptr)` calls
284
+ `operator delete(ptr)`.
285
 
286
  ``` cpp
287
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
288
+ void operator delete[](void* ptr, std::size_t size, const std::nothrow_t&) noexcept;
289
  ```
290
 
291
  *Effects:* The *deallocation
292
  function* ([[basic.stc.dynamic.deallocation]]) called by the
293
  implementation to render the value of `ptr` invalid when the constructor
294
  invoked from a nothrow placement version of the array *new-expression*
295
  throws an exception.
296
 
297
+ *Replaceable:* a C++program may define a function with signature
298
+ `void operator delete[](void* ptr, const std::nothrow_t&) noexcept` that
299
+ displaces the default version defined by the C++standard library. If
300
+ this function (without `size` parameter) is defined, the program should
301
+ also define
302
+ `void operator delete[](void* ptr, std::size_t size, const std::nothrow_t&) noexcept`.
303
+ If this function with `size` parameter is defined, the program shall
304
+ also define the version without the `size` parameter. The default
305
+ behavior below may change in the future, which will require replacing
306
+ both deallocation functions when replacing the allocation function.
307
 
308
  *Requires:* If an implementation has strict pointer
309
  safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
310
  safely-derived pointer.
311
 
312
+ *Requires:* If present, the `std::size_t size` argument must equal the
313
+ size argument passed to the allocation function that returned `ptr`.
314
+
315
+ *Required behavior:* Calls to
316
+ `operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
317
+ may be changed to calls to
318
+ `operator delete[](void* ptr, const std::nothrow_t&)` without affecting
319
+ memory allocation. A conforming implementation is for
320
+ `operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
321
+ to simply call `operator delete[](void* ptr, const std::nothrow_t&)`.
322
+
323
+ *Default behavior:*
324
+ `operator delete[](void* ptr, std::size_t size, const std::nothrow_t&)`
325
+ calls `operator delete[](ptr, std::nothrow)`, and
326
+ `operator delete[](void* ptr, const std::nothrow_t&)` calls
327
+ `operator delete[](ptr)`.
328
 
329
  #### Placement forms <a id="new.delete.placement">[[new.delete.placement]]</a>
330
 
331
  These functions are reserved, a C++program may not define functions that
332
  displace the versions in the Standard C++library ([[constraints]]). The
 
387
 
388
  #### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
389
 
390
  For purposes of determining the existence of data races, the library
391
  versions of `operator new`, user replacement versions of global
392
+ `operator new`, the C standard library functions `calloc` and `malloc`,
393
+ the library versions of `operator delete`, user replacement versions of
394
+ `operator delete`, the C standard library function `free`, and the C
395
+ standard library function `realloc` shall not introduce a data race (
396
+ [[res.on.data.races]]). Calls to these functions that allocate or
397
+ deallocate a particular unit of storage shall occur in a single total
398
+ order, and each such deallocation call shall happen before (
399
+ [[intro.multithread]]) the next allocation (if any) in this order.
 
 
 
 
400
 
401
  ### Storage allocation errors <a id="alloc.errors">[[alloc.errors]]</a>
402
 
403
  #### Class `bad_alloc` <a id="bad.alloc">[[bad.alloc]]</a>
404