|
4220 | 4220 | \terminal{::}\opt{} \terminal{delete [ ]} cast-expression
|
4221 | 4221 | \end{bnf}
|
4222 | 4222 |
|
4223 |
| -The first alternative is for non-array objects, and the second is for arrays. Whenever |
4224 |
| -the \tcode{delete} keyword is immediately followed by empty square brackets, it shall be |
4225 |
| -interpreted as the second alternative.\footnote{A lambda expression with a |
4226 |
| -\grammarterm{lambda-introducer} that consists of |
4227 |
| -empty square brackets can follow the \tcode{delete} keyword if the lambda expression is |
| 4223 | +The first alternative is a |
| 4224 | +\defnx{single-object delete expression}{delete!single-object}, and the |
| 4225 | +second is an \defnx{array delete expression}{delete!array}. |
| 4226 | +Whenever the \tcode{delete} keyword is immediately followed by empty square |
| 4227 | +brackets, it shall be interpreted as the second alternative.\footnote{A lambda |
| 4228 | +expression with a \grammarterm{lambda-introducer} that consists of empty square |
| 4229 | +brackets can follow the \tcode{delete} keyword if the lambda expression is |
4228 | 4230 | enclosed in parentheses.}
|
4229 | 4231 | The operand shall be of pointer to object type or of class type. If of
|
4230 | 4232 | class type, the operand is contextually implicitly converted\iref{conv}
|
|
4236 | 4238 | \tcode{void}.
|
4237 | 4239 |
|
4238 | 4240 | \pnum
|
4239 |
| -\indextext{\idxcode{delete}!object}% |
| 4241 | +\indextext{\idxcode{delete}!single-object}% |
4240 | 4242 | If the operand has a class type, the operand is converted to a pointer
|
4241 | 4243 | type by calling the above-mentioned conversion function, and the
|
4242 | 4244 | converted operand is used in place of the original operand for the
|
4243 | 4245 | remainder of this subclause.
|
4244 |
| -In the first alternative |
4245 |
| -(\defnx{delete object}{object!delete}), the value of the operand of \tcode{delete} may |
4246 |
| -be a null pointer value, a pointer to a non-array object |
| 4246 | +In a single-object delete expression, the value of the operand of |
| 4247 | +\tcode{delete} may be a null pointer value, a pointer to a non-array object |
4247 | 4248 | created by a previous \grammarterm{new-expression},
|
4248 | 4249 | or a pointer to a
|
4249 | 4250 | subobject\iref{intro.object} representing a base class of such an
|
4250 | 4251 | object\iref{class.derived}. If not, the behavior is undefined.
|
4251 | 4252 | \indextext{array!\idxcode{delete}}%
|
4252 |
| -In the second alternative (\defnx{delete array}{\idxcode{delete}!array}), the value of the |
4253 |
| -operand of \tcode{delete} |
4254 |
| -may be a null pointer value or a pointer value |
4255 |
| -that resulted from |
| 4253 | +In an array delete expression, the value of the operand of \tcode{delete} |
| 4254 | +may be a null pointer value or a pointer value that resulted from |
4256 | 4255 | a previous array \grammarterm{new-expression}.\footnote{For nonzero-length
|
4257 | 4256 | arrays, this is the same as a pointer to the first
|
4258 | 4257 | element of the array created by that \grammarterm{new-expression}.
|
|
4272 | 4271 |
|
4273 | 4272 | \pnum
|
4274 | 4273 | \indextext{\idxcode{delete}!undefined}%
|
4275 |
| -In the first alternative (\term{delete object}), if the static type of |
4276 |
| -the object to be deleted is different from its dynamic type, the static type shall be |
4277 |
| -a base class of the dynamic type of the object to be deleted and the static type shall |
4278 |
| -have a virtual destructor or the behavior is undefined. In the second |
4279 |
| -alternative (\term{delete array}) if the dynamic type of the object to |
4280 |
| -be deleted differs from its static type, the behavior is undefined. |
| 4274 | +In a single-object delete expression, if the static type of the object to be |
| 4275 | +deleted is different from its dynamic type, the static type shall be a base |
| 4276 | +class of the dynamic type of the object to be deleted and the static type shall |
| 4277 | +have a virtual destructor or the behavior is undefined. In an array delete |
| 4278 | +expression, if the dynamic type of the object to be deleted differs from its |
| 4279 | +static type, the behavior is undefined. |
4281 | 4280 |
|
4282 | 4281 | \pnum
|
4283 | 4282 | The \grammarterm{cast-expression} in a \grammarterm{delete-expression} shall
|
|
4382 | 4381 | \pnum
|
4383 | 4382 | When a \grammarterm{delete-expression}
|
4384 | 4383 | is executed, the selected deallocation function shall be called with
|
4385 |
| -the address of the most-derived object in the \term{delete object} case, or |
4386 |
| -the address of the object suitably adjusted for |
4387 |
| -the array allocation overhead\iref{expr.new} in the \term{delete array} case, |
| 4384 | +the address of the most-derived object in a single-object delete expression, or |
| 4385 | +the address of the object suitably adjusted for the array allocation |
| 4386 | +overhead\iref{expr.new} in an array delete expression, |
4388 | 4387 | as its first argument.
|
4389 | 4388 | If a deallocation function
|
4390 | 4389 | with a parameter of type \tcode{std::align_val_t}
|
|
0 commit comments