From Jason Turner

[expr.delete]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmph0n01vpe/{from.md → to.md} +27 -33
tmp/tmph0n01vpe/{from.md → to.md} RENAMED
@@ -10,30 +10,26 @@ delete-expression:
10
  ```
11
 
12
  The first alternative is a *single-object delete expression*, and the
13
  second is an *array delete expression*. Whenever the `delete` keyword is
14
  immediately followed by empty square brackets, it shall be interpreted
15
- as the second alternative.[^25]
16
 
17
- The operand shall be of pointer to object type or of class type. If of
18
- class type, the operand is contextually implicitly converted [[conv]] to
19
- a pointer to object type.[^26]
 
 
20
 
21
- The *delete-expression* has type `void`.
22
-
23
- If the operand has a class type, the operand is converted to a pointer
24
- type by calling the above-mentioned conversion function, and the
25
- converted operand is used in place of the original operand for the
26
- remainder of this subclause. In a single-object delete expression, the
27
- value of the operand of `delete` may be a null pointer value, a pointer
28
- value that resulted from a previous non-array *new-expression*, or a
29
- pointer to a base class subobject of an object created by such a
30
- *new-expression*. If not, the behavior is undefined. In an array delete
31
- expression, the value of the operand of `delete` may be a null pointer
32
- value or a pointer value that resulted from a previous array
33
- *new-expression* whose allocation function was not a non-allocating form
34
- [[new.delete.placement]].[^27]
35
 
36
  If not, the behavior is undefined.
37
 
38
  [*Note 1*: This means that the syntax of the *delete-expression* must
39
  match the type of the object allocated by `new`, not the syntax of the
@@ -51,24 +47,21 @@ delete, the static type shall be a base class of the dynamic type of the
51
  object to be deleted and the static type shall have a virtual destructor
52
  or the behavior is undefined. In an array delete expression, if the
53
  dynamic type of the object to be deleted is not similar to its static
54
  type, the behavior is undefined.
55
 
56
- The *cast-expression* in a *delete-expression* shall be evaluated
57
- exactly once.
58
-
59
  If the object being deleted has incomplete class type at the point of
60
- deletion and the complete class has a non-trivial destructor or a
61
- deallocation function, the behavior is undefined.
62
 
63
  If the value of the operand of the *delete-expression* is not a null
64
  pointer value and the selected deallocation function (see below) is not
65
- a destroying operator delete, the *delete-expression* will invoke the
66
- destructor (if any) for the object or the elements of the array being
67
- deleted. In the case of an array, the elements will be destroyed in
68
- order of decreasing address (that is, in reverse order of the completion
69
- of their constructor; see  [[class.base.init]]).
 
70
 
71
  If the value of the operand of the *delete-expression* is not a null
72
  pointer value, then:
73
 
74
  - If the allocation call for the *new-expression* for the object to be
@@ -125,12 +118,11 @@ declarations other than of usual deallocation functions
125
 
126
  [*Note 5*: If only a placement deallocation function is found in a
127
  class, the program is ill-formed because the lookup set is empty
128
  [[basic.lookup]]. — *end note*]
129
 
130
- If more than one deallocation function is found, the function to be
131
- called is selected as follows:
132
 
133
  - If any of the deallocation functions is a destroying operator delete,
134
  all deallocation functions that are not destroying operator deletes
135
  are eliminated from further consideration.
136
  - If the type has new-extended alignment, a function with a parameter of
@@ -146,10 +138,15 @@ called is selected as follows:
146
  or a (possibly multidimensional) array thereof, the function with a
147
  parameter of type `std::size_t` is selected.
148
  - Otherwise, it is unspecified whether a deallocation function with a
149
  parameter of type `std::size_t` is selected.
150
 
 
 
 
 
 
151
  For a single-object delete expression, the deleted object is the object
152
  A pointed to by the operand if the static type of A does not have a
153
  virtual destructor, and the most-derived object of A otherwise.
154
 
155
  [*Note 6*: If the deallocation function is not a destroying operator
@@ -180,8 +177,5 @@ passed as the corresponding argument.
180
  function, and either the first argument was not the result of a prior
181
  call to a replaceable allocation function or the second or third
182
  argument was not the corresponding argument in said call, the behavior
183
  is undefined [[new.delete.single]], [[new.delete.array]]. — *end note*]
184
 
185
- Access and ambiguity control are done for both the deallocation function
186
- and the destructor [[class.dtor]], [[class.free]].
187
-
 
10
  ```
11
 
12
  The first alternative is a *single-object delete expression*, and the
13
  second is an *array delete expression*. Whenever the `delete` keyword is
14
  immediately followed by empty square brackets, it shall be interpreted
15
+ as the second alternative.[^23]
16
 
17
+ If the operand is of class type, it is contextually implicitly converted
18
+ [[conv]] to a pointer to object type and the converted operand is used
19
+ in place of the original operand for the remainder of this subclause.
20
+ Otherwise, it shall be a prvalue of pointer to object type. The
21
+ *delete-expression* has type `void`.
22
 
23
+ In a single-object delete expression, the value of the operand of
24
+ `delete` may be a null pointer value, a pointer value that resulted from
25
+ a previous non-array *new-expression*, or a pointer to a base class
26
+ subobject of an object created by such a *new-expression*. If not, the
27
+ behavior is undefined. In an array delete expression, the value of the
28
+ operand of `delete` may be a null pointer value or a pointer value that
29
+ resulted from a previous array *new-expression* whose allocation
30
+ function was not a non-allocating form [[new.delete.placement]].[^24]
 
 
 
 
 
 
31
 
32
  If not, the behavior is undefined.
33
 
34
  [*Note 1*: This means that the syntax of the *delete-expression* must
35
  match the type of the object allocated by `new`, not the syntax of the
 
47
  object to be deleted and the static type shall have a virtual destructor
48
  or the behavior is undefined. In an array delete expression, if the
49
  dynamic type of the object to be deleted is not similar to its static
50
  type, the behavior is undefined.
51
 
 
 
 
52
  If the object being deleted has incomplete class type at the point of
53
+ deletion, the program is ill-formed.
 
54
 
55
  If the value of the operand of the *delete-expression* is not a null
56
  pointer value and the selected deallocation function (see below) is not
57
+ a destroying operator delete, evaluating the *delete-expression* invokes
58
+ the destructor (if any) for the object or the elements of the array
59
+ being deleted. The destructor shall be accessible from the point where
60
+ the *delete-expression* appears. In the case of an array, the elements
61
+ are destroyed in order of decreasing address (that is, in reverse order
62
+ of the completion of their constructor; see  [[class.base.init]]).
63
 
64
  If the value of the operand of the *delete-expression* is not a null
65
  pointer value, then:
66
 
67
  - If the allocation call for the *new-expression* for the object to be
 
118
 
119
  [*Note 5*: If only a placement deallocation function is found in a
120
  class, the program is ill-formed because the lookup set is empty
121
  [[basic.lookup]]. — *end note*]
122
 
123
+ The deallocation function to be called is selected as follows:
 
124
 
125
  - If any of the deallocation functions is a destroying operator delete,
126
  all deallocation functions that are not destroying operator deletes
127
  are eliminated from further consideration.
128
  - If the type has new-extended alignment, a function with a parameter of
 
138
  or a (possibly multidimensional) array thereof, the function with a
139
  parameter of type `std::size_t` is selected.
140
  - Otherwise, it is unspecified whether a deallocation function with a
141
  parameter of type `std::size_t` is selected.
142
 
143
+ Unless the deallocation function is selected at the point of definition
144
+ of the dynamic type’s virtual destructor, the selected deallocation
145
+ function shall be accessible from the point where the
146
+ *delete-expression* appears.
147
+
148
  For a single-object delete expression, the deleted object is the object
149
  A pointed to by the operand if the static type of A does not have a
150
  virtual destructor, and the most-derived object of A otherwise.
151
 
152
  [*Note 6*: If the deallocation function is not a destroying operator
 
177
  function, and either the first argument was not the result of a prior
178
  call to a replaceable allocation function or the second or third
179
  argument was not the corresponding argument in said call, the behavior
180
  is undefined [[new.delete.single]], [[new.delete.array]]. — *end note*]
181