|
3993 | 3993 | \terminal{::}\opt{} \terminal{delete [ ]} cast-expression |
3994 | 3994 | \end{bnf} |
3995 | 3995 |
|
3996 | | -The first alternative is for non-array objects, and the second is for arrays. Whenever |
3997 | | -the \tcode{delete} keyword is immediately followed by empty square brackets, it shall be |
3998 | | -interpreted as the second alternative.\footnote{A lambda expression with a |
3999 | | -\grammarterm{lambda-introducer} that consists of |
4000 | | -empty square brackets can follow the \tcode{delete} keyword if the lambda expression is |
| 3996 | +The first alternative is a |
| 3997 | +\defnx{single-object delete expression}{delete!single-object}, and the |
| 3998 | +second is an \defnx{array delete expression}{delete!array}. |
| 3999 | +Whenever the \tcode{delete} keyword is immediately followed by empty square |
| 4000 | +brackets, it shall be interpreted as the second alternative.\footnote{A lambda |
| 4001 | +expression with a \grammarterm{lambda-introducer} that consists of empty square |
| 4002 | +brackets can follow the \tcode{delete} keyword if the lambda expression is |
4001 | 4003 | enclosed in parentheses.} |
4002 | 4004 | The operand shall be of pointer to object type or of class type. If of |
4003 | 4005 | class type, the operand is contextually implicitly converted\iref{conv} |
|
4009 | 4011 | \tcode{void}. |
4010 | 4012 |
|
4011 | 4013 | \pnum |
4012 | | -\indextext{\idxcode{delete}!object}% |
| 4014 | +\indextext{\idxcode{delete}!single-object}% |
4013 | 4015 | If the operand has a class type, the operand is converted to a pointer |
4014 | 4016 | type by calling the above-mentioned conversion function, and the |
4015 | 4017 | converted operand is used in place of the original operand for the |
4016 | 4018 | remainder of this section. |
4017 | | -In the first alternative |
4018 | | -(\defnx{delete object}{object!delete}), the value of the operand of \tcode{delete} may |
4019 | | -be a null pointer value, a pointer to a non-array object |
| 4019 | +In a single-object delete expression, the value of the operand of |
| 4020 | +\tcode{delete} may be a null pointer value, a pointer to a non-array object |
4020 | 4021 | created by a previous \grammarterm{new-expression}, |
4021 | 4022 | or a pointer to a |
4022 | 4023 | subobject\iref{intro.object} representing a base class of such an |
4023 | 4024 | object\iref{class.derived}. If not, the behavior is undefined. |
4024 | 4025 | \indextext{array!\idxcode{delete}}% |
4025 | | -In the second alternative (\defnx{delete array}{\idxcode{delete}!array}), the value of the |
4026 | | -operand of \tcode{delete} |
4027 | | -may be a null pointer value or a pointer value |
4028 | | -that resulted from |
| 4026 | +In an array delete expression, the value of the operand of \tcode{delete} |
| 4027 | +may be a null pointer value or a pointer value that resulted from |
4029 | 4028 | a previous array \grammarterm{new-expression}.\footnote{For nonzero-length |
4030 | 4029 | arrays, this is the same as a pointer to the first |
4031 | 4030 | element of the array created by that \grammarterm{new-expression}. |
|
4045 | 4044 |
|
4046 | 4045 | \pnum |
4047 | 4046 | \indextext{\idxcode{delete}!undefined}% |
4048 | | -In the first alternative (delete object), if the static type of |
4049 | | -the object to be deleted is different from its dynamic type, the static type shall be |
4050 | | -a base class of the dynamic type of the object to be deleted and the static type shall |
4051 | | -have a virtual destructor or the behavior is undefined. In the second |
4052 | | -alternative (delete array) if the dynamic type of the object to |
4053 | | -be deleted differs from its static type, the behavior is undefined. |
| 4047 | +In a single-object delete expression, if the static type of the object to be |
| 4048 | +deleted is different from its dynamic type, the static type shall be a base |
| 4049 | +class of the dynamic type of the object to be deleted and the static type shall |
| 4050 | +have a virtual destructor or the behavior is undefined. In an array delete |
| 4051 | +expression, if the dynamic type of the object to be deleted differs from its |
| 4052 | +static type, the behavior is undefined. |
4054 | 4053 |
|
4055 | 4054 | \pnum |
4056 | 4055 | The \grammarterm{cast-expression} in a \grammarterm{delete-expression} shall |
|
4155 | 4154 | \pnum |
4156 | 4155 | When a \grammarterm{delete-expression} |
4157 | 4156 | is executed, the selected deallocation function shall be called with |
4158 | | -the address of the most-derived object in the \term{delete object} case, or |
4159 | | -the address of the object suitably adjusted for |
4160 | | -the array allocation overhead\iref{expr.new} in the \term{delete array} case, |
| 4157 | +the address of the most-derived object in a single-object delete expression, or |
| 4158 | +the address of the object suitably adjusted for the array allocation |
| 4159 | +overhead\iref{expr.new} in an array delete expression, |
4161 | 4160 | as its first argument. |
4162 | 4161 | If a deallocation function |
4163 | 4162 | with a parameter of type \tcode{std::align_val_t} |
|
0 commit comments