From Jason Turner

[new.delete]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpq7q33s__/{from.md → to.md} +53 -75
tmp/tmpq7q33s__/{from.md → to.md} RENAMED
@@ -1,7 +1,9 @@
1
  ### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
2
 
 
 
3
  Except where otherwise specified, the provisions of 
4
  [[basic.stc.dynamic]] apply to the library versions of `operator new`
5
  and `operator
6
  delete`. If the value of an alignment argument passed to any of these
7
  functions is not a valid alignment value, the behavior is undefined.
@@ -82,10 +84,23 @@ void operator delete(void* ptr) noexcept;
82
  void operator delete(void* ptr, std::size_t size) noexcept;
83
  void operator delete(void* ptr, std::align_val_t alignment) noexcept;
84
  void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
85
  ```
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
88
  called by a *delete-expression*[[expr.delete]] to render the value of
89
  `ptr` invalid.
90
 
91
  *Replaceable:* A C++ program may define functions with any of these
@@ -95,31 +110,14 @@ by the C++ standard library.
95
  If a function without a `size` parameter is defined, the program should
96
  also define the corresponding function with a `size` parameter. If a
97
  function with a `size` parameter is defined, the program shall also
98
  define the corresponding version without the `size` parameter.
99
 
100
- [*Note 1*: The default behavior below may change in the future, which
101
  will require replacing both deallocation functions when replacing the
102
  allocation function. — *end note*]
103
 
104
- *Preconditions:* `ptr` is a null pointer or its value represents the
105
- address of a block of memory allocated by an earlier call to a (possibly
106
- replaced) `operator new(std::size_t)` or
107
- `operator new(std::size_t, std::align_val_t)` which has not been
108
- invalidated by an intervening call to `operator delete`.
109
-
110
- *Preconditions:* If an implementation has strict pointer
111
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
112
- pointer.
113
-
114
- *Preconditions:* If the `alignment` parameter is not present, `ptr` was
115
- returned by an allocation function without an `alignment` parameter. If
116
- present, the `alignment` argument is equal to the `alignment` argument
117
- passed to the allocation function that returned `ptr`. If present, the
118
- `size` argument is equal to the `size` argument passed to the allocation
119
- function that returned `ptr`.
120
-
121
  *Required behavior:* A call to an `operator delete` with a `size`
122
  parameter may be changed to a call to the corresponding
123
  `operator delete` without a `size` parameter, without affecting memory
124
  allocation.
125
 
@@ -145,34 +143,30 @@ reclaimed storage will be allocated by subsequent calls to
145
  ``` cpp
146
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
147
  void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
148
  ```
149
 
 
 
 
 
 
 
 
 
 
 
 
150
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
151
  called by the implementation to render the value of `ptr` invalid when
152
  the constructor invoked from a nothrow placement version of the
153
  *new-expression* throws an exception.
154
 
155
  *Replaceable:* A C++ program may define functions with either of these
156
  function signatures, and thereby displace the default versions defined
157
  by the C++ standard library.
158
 
159
- *Preconditions:* `ptr` is a null pointer or its value represents the
160
- address of a block of memory allocated by an earlier call to a (possibly
161
- replaced) `operator new(std::size_t)` or
162
- `operator new(std::size_t, std::align_val_t)` which has not been
163
- invalidated by an intervening call to `operator delete`.
164
-
165
- *Preconditions:* If an implementation has strict pointer
166
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
167
- pointer.
168
-
169
- *Preconditions:* If the `alignment` parameter is not present, `ptr` was
170
- returned by an allocation function without an `alignment` parameter. If
171
- present, the `alignment` argument is equal to the `alignment` argument
172
- passed to the allocation function that returned `ptr`.
173
-
174
  *Default behavior:* Calls `operator delete(ptr)`, or
175
  `operator delete(ptr, alignment)`, respectively.
176
 
177
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
178
 
@@ -182,11 +176,11 @@ passed to the allocation function that returned `ptr`.
182
  ```
183
 
184
  *Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
185
  called by the array form of a *new-expression*[[expr.new]] to allocate
186
  `size` bytes of storage. The second form is called for a type with
187
- new-extended alignment, and the first form is called otherwise. [^33]
188
 
189
  *Replaceable:* A C++ program may define functions with either of these
190
  function signatures, and thereby displace the default versions defined
191
  by the C++ standard library.
192
 
@@ -228,10 +222,23 @@ void operator delete[](void* ptr) noexcept;
228
  void operator delete[](void* ptr, std::size_t size) noexcept;
229
  void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
230
  void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
231
  ```
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
234
  called by the array form of a *delete-expression* to render the value of
235
  `ptr` invalid.
236
 
237
  *Replaceable:* A C++ program may define functions with any of these
@@ -241,31 +248,14 @@ by the C++ standard library.
241
  If a function without a `size` parameter is defined, the program should
242
  also define the corresponding function with a `size` parameter. If a
243
  function with a `size` parameter is defined, the program shall also
244
  define the corresponding version without the `size` parameter.
245
 
246
- [*Note 1*: The default behavior below may change in the future, which
247
  will require replacing both deallocation functions when replacing the
248
  allocation function. — *end note*]
249
 
250
- *Preconditions:* `ptr` is a null pointer or its value represents the
251
- address of a block of memory allocated by an earlier call to a (possibly
252
- replaced) `operator new[](std::size_t)` or
253
- `operator new[](std::size_t, std::align_val_t)` which has not been
254
- invalidated by an intervening call to `operator delete[]`.
255
-
256
- *Preconditions:* If an implementation has strict pointer
257
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
258
- pointer.
259
-
260
- *Preconditions:* If the `alignment` parameter is not present, `ptr` was
261
- returned by an allocation function without an `alignment` parameter. If
262
- present, the `alignment` argument is equal to the `alignment` argument
263
- passed to the allocation function that returned `ptr`. If present, the
264
- `size` argument is equal to the `size` argument passed to the allocation
265
- function that returned `ptr`.
266
-
267
  *Required behavior:* A call to an `operator delete[]` with a `size`
268
  parameter may be changed to a call to the corresponding
269
  `operator delete[]` without a `size` parameter, without affecting memory
270
  allocation.
271
 
@@ -282,34 +272,30 @@ function.
282
  ``` cpp
283
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
284
  void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
285
  ```
286
 
 
 
 
 
 
 
 
 
 
 
 
287
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
288
  called by the implementation to render the value of `ptr` invalid when
289
  the constructor invoked from a nothrow placement version of the array
290
  *new-expression* throws an exception.
291
 
292
  *Replaceable:* A C++ program may define functions with either of these
293
  function signatures, and thereby displace the default versions defined
294
  by the C++ standard library.
295
 
296
- *Preconditions:* `ptr` is a null pointer or its value represents the
297
- address of a block of memory allocated by an earlier call to a (possibly
298
- replaced) `operator new[](std::size_t)` or
299
- `operator new[](std::size_t, std::align_val_t)` which has not been
300
- invalidated by an intervening call to `operator delete[]`.
301
-
302
- *Preconditions:* If an implementation has strict pointer
303
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
304
- pointer.
305
-
306
- *Preconditions:* If the `alignment` parameter is not present, `ptr` was
307
- returned by an allocation function without an `alignment` parameter. If
308
- present, the `alignment` argument is equal to the `alignment` argument
309
- passed to the allocation function that returned `ptr`.
310
-
311
  *Default behavior:* Calls `operator delete[](ptr)`, or
312
  `operator delete[](ptr, alignment)`, respectively.
313
 
314
  #### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
315
 
@@ -349,28 +335,20 @@ Something* p = new (place) Something();
349
  void operator delete(void* ptr, void*) noexcept;
350
  ```
351
 
352
  *Effects:* Intentionally performs no action.
353
 
354
- *Preconditions:* If an implementation has strict pointer
355
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
356
- pointer.
357
-
358
  *Remarks:* Default function called when any part of the initialization
359
  in a placement *new-expression* that invokes the library’s non-array
360
  placement operator new terminates by throwing an exception [[expr.new]].
361
 
362
  ``` cpp
363
  void operator delete[](void* ptr, void*) noexcept;
364
  ```
365
 
366
  *Effects:* Intentionally performs no action.
367
 
368
- *Preconditions:* If an implementation has strict pointer
369
- safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
370
- pointer.
371
-
372
  *Remarks:* Default function called when any part of the initialization
373
  in a placement *new-expression* that invokes the library’s array
374
  placement operator new terminates by throwing an exception [[expr.new]].
375
 
376
  #### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>
 
1
  ### Storage allocation and deallocation <a id="new.delete">[[new.delete]]</a>
2
 
3
+ #### General <a id="new.delete.general">[[new.delete.general]]</a>
4
+
5
  Except where otherwise specified, the provisions of 
6
  [[basic.stc.dynamic]] apply to the library versions of `operator new`
7
  and `operator
8
  delete`. If the value of an alignment argument passed to any of these
9
  functions is not a valid alignment value, the behavior is undefined.
 
84
  void operator delete(void* ptr, std::size_t size) noexcept;
85
  void operator delete(void* ptr, std::align_val_t alignment) noexcept;
86
  void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
87
  ```
88
 
89
+ *Preconditions:* `ptr` is a null pointer or its value represents the
90
+ address of a block of memory allocated by an earlier call to a (possibly
91
+ replaced) `operator new(std::size_t)` or
92
+ `operator new(std::size_t, std::align_val_t)` which has not been
93
+ invalidated by an intervening call to `operator delete`.
94
+
95
+ If the `alignment` parameter is not present, `ptr` was returned by an
96
+ allocation function without an `alignment` parameter. If present, the
97
+ `alignment` argument is equal to the `alignment` argument passed to the
98
+ allocation function that returned `ptr`. If present, the `size` argument
99
+ is equal to the `size` argument passed to the allocation function that
100
+ returned `ptr`.
101
+
102
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
103
  called by a *delete-expression*[[expr.delete]] to render the value of
104
  `ptr` invalid.
105
 
106
  *Replaceable:* A C++ program may define functions with any of these
 
110
  If a function without a `size` parameter is defined, the program should
111
  also define the corresponding function with a `size` parameter. If a
112
  function with a `size` parameter is defined, the program shall also
113
  define the corresponding version without the `size` parameter.
114
 
115
+ [*Note 1*: The default behavior below might change in the future, which
116
  will require replacing both deallocation functions when replacing the
117
  allocation function. — *end note*]
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  *Required behavior:* A call to an `operator delete` with a `size`
120
  parameter may be changed to a call to the corresponding
121
  `operator delete` without a `size` parameter, without affecting memory
122
  allocation.
123
 
 
143
  ``` cpp
144
  void operator delete(void* ptr, const std::nothrow_t&) noexcept;
145
  void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
146
  ```
147
 
148
+ *Preconditions:* `ptr` is a null pointer or its value represents the
149
+ address of a block of memory allocated by an earlier call to a (possibly
150
+ replaced) `operator new(std::size_t)` or
151
+ `operator new(std::size_t, std::align_val_t)` which has not been
152
+ invalidated by an intervening call to `operator delete`.
153
+
154
+ If the `alignment` parameter is not present, `ptr` was returned by an
155
+ allocation function without an `alignment` parameter. If present, the
156
+ `alignment` argument is equal to the `alignment` argument passed to the
157
+ allocation function that returned `ptr`.
158
+
159
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
160
  called by the implementation to render the value of `ptr` invalid when
161
  the constructor invoked from a nothrow placement version of the
162
  *new-expression* throws an exception.
163
 
164
  *Replaceable:* A C++ program may define functions with either of these
165
  function signatures, and thereby displace the default versions defined
166
  by the C++ standard library.
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  *Default behavior:* Calls `operator delete(ptr)`, or
169
  `operator delete(ptr, alignment)`, respectively.
170
 
171
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
172
 
 
176
  ```
177
 
178
  *Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
179
  called by the array form of a *new-expression*[[expr.new]] to allocate
180
  `size` bytes of storage. The second form is called for a type with
181
+ new-extended alignment, and the first form is called otherwise.[^31]
182
 
183
  *Replaceable:* A C++ program may define functions with either of these
184
  function signatures, and thereby displace the default versions defined
185
  by the C++ standard library.
186
 
 
222
  void operator delete[](void* ptr, std::size_t size) noexcept;
223
  void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
224
  void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
225
  ```
226
 
227
+ *Preconditions:* `ptr` is a null pointer or its value represents the
228
+ address of a block of memory allocated by an earlier call to a (possibly
229
+ replaced) `operator new[](std::size_t)` or
230
+ `operator new[](std::size_t, std::align_val_t)` which has not been
231
+ invalidated by an intervening call to `operator delete[]`.
232
+
233
+ If the `alignment` parameter is not present, `ptr` was returned by an
234
+ allocation function without an `alignment` parameter. If present, the
235
+ `alignment` argument is equal to the `alignment` argument passed to the
236
+ allocation function that returned `ptr`. If present, the `size` argument
237
+ is equal to the `size` argument passed to the allocation function that
238
+ returned `ptr`.
239
+
240
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
241
  called by the array form of a *delete-expression* to render the value of
242
  `ptr` invalid.
243
 
244
  *Replaceable:* A C++ program may define functions with any of these
 
248
  If a function without a `size` parameter is defined, the program should
249
  also define the corresponding function with a `size` parameter. If a
250
  function with a `size` parameter is defined, the program shall also
251
  define the corresponding version without the `size` parameter.
252
 
253
+ [*Note 1*: The default behavior below might change in the future, which
254
  will require replacing both deallocation functions when replacing the
255
  allocation function. — *end note*]
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  *Required behavior:* A call to an `operator delete[]` with a `size`
258
  parameter may be changed to a call to the corresponding
259
  `operator delete[]` without a `size` parameter, without affecting memory
260
  allocation.
261
 
 
272
  ``` cpp
273
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
274
  void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
275
  ```
276
 
277
+ *Preconditions:* `ptr` is a null pointer or its value represents the
278
+ address of a block of memory allocated by an earlier call to a (possibly
279
+ replaced) `operator new[](std::size_t)` or
280
+ `operator new[](std::size_t, std::align_val_t)` which has not been
281
+ invalidated by an intervening call to `operator delete[]`.
282
+
283
+ If the `alignment` parameter is not present, `ptr` was returned by an
284
+ allocation function without an `alignment` parameter. If present, the
285
+ `alignment` argument is equal to the `alignment` argument passed to the
286
+ allocation function that returned `ptr`.
287
+
288
  *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
289
  called by the implementation to render the value of `ptr` invalid when
290
  the constructor invoked from a nothrow placement version of the array
291
  *new-expression* throws an exception.
292
 
293
  *Replaceable:* A C++ program may define functions with either of these
294
  function signatures, and thereby displace the default versions defined
295
  by the C++ standard library.
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  *Default behavior:* Calls `operator delete[](ptr)`, or
298
  `operator delete[](ptr, alignment)`, respectively.
299
 
300
  #### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
301
 
 
335
  void operator delete(void* ptr, void*) noexcept;
336
  ```
337
 
338
  *Effects:* Intentionally performs no action.
339
 
 
 
 
 
340
  *Remarks:* Default function called when any part of the initialization
341
  in a placement *new-expression* that invokes the library’s non-array
342
  placement operator new terminates by throwing an exception [[expr.new]].
343
 
344
  ``` cpp
345
  void operator delete[](void* ptr, void*) noexcept;
346
  ```
347
 
348
  *Effects:* Intentionally performs no action.
349
 
 
 
 
 
350
  *Remarks:* Default function called when any part of the initialization
351
  in a placement *new-expression* that invokes the library’s array
352
  placement operator new terminates by throwing an exception [[expr.new]].
353
 
354
  #### Data races <a id="new.delete.dataraces">[[new.delete.dataraces]]</a>