This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-28


2728. Evaluation of conversions in a delete-expression

Section: 7.6.2.9  [expr.delete]     Status: tentatively ready     Submitter: Jiang An     Date: 2023-05-05

Subclause 7.6.2.9 [expr.delete] paragraph 4 specifies:

The cast-expression in a delete-expression shall be evaluated exactly once.

Due to the reference to the syntactic non-terminal cast-expression, it is unclear whether that includes the conversion to pointer type specified in 7.6.2.9 [expr.delete] paragraph 2.

Proposed resolution (approved by CWG 2024-03-01) [SUPERSEDED]:

  1. Change in 7.6.2.9 [expr.delete] paragraph 1 and paragraph 2 as follows:

    ... The operand shall be of class type or a prvalue of pointer to object type or of class type. If of class type, the operand is contextually implicitly converted (7.3 [conv]) to a prvalue pointer to object type. [ Footnote: ... ] The converted operand is used in place of the original operand for the remainder of this subclause. The delete-expression has type void.

    If the operand has a class type, the operand is converted to a pointer type by calling the above-mentioned conversion function, and the converted operand is used in place of the original operand for the remainder of this subclause. ...

  2. Change in 7.6.2.9 [expr.delete] paragraph 4 as follows:

    The cast-expression in operand of a delete-expression shall be evaluated exactly once.

Proposed resolution (approved by CWG 2024-03-20):

  1. Change in 7.6.2.9 [expr.delete] paragraph 1 and paragraph 2 as follows:

    ... The first alternative is a single-object delete expression, and the second is an array delete expression. Whenever the delete keyword is immediately followed by empty square brackets, it shall be interpreted as the second alternative. [ Footnote: ... ] If the operand is of class type, it is contextually implicitly converted (7.3 [conv]) to a pointer to object type and the converted operand is used in place of the original operand for the remainder of this subclause. [ Footnote: ...] Otherwise, it shall be a prvalue of pointer to object type. The delete-expression has type void.

    If the operand has a class type, the operand is converted to a pointer type by calling the above-mentioned conversion function, and the converted operand is used in place of the original operand for the remainder of this subclause. ...

  2. Delete 7.6.2.9 [expr.delete] paragraph 4:

    The cast-expression in a delete-expression shall be evaluated exactly once.