Title
Deleting a pointer to an incomplete enumeration type
Status
nad
Section
7.6.2.9 [expr.delete]
Submitter
Jiang An

Created on 2024-08-14.00:00:00 last changed 1 month ago

Messages

Date: 2024-09-25.17:32:08

CWG 2024-09-13

Since an enumeration type can never have a user-declared destructor, there is no risk of introducing undefined behavior that would be prevented by making deletions involving incomplete enumeration types ill-formed. In short, the situation discussed in this issue is harmless and thus lacks rationale to be made ill-formed.

Date: 2024-08-15.19:36:25

Suggested resolution:

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

If the static type of the object being to be deleted has incomplete class type at the point of deletion, the program is ill-formed.
Date: 2024-08-14.00:00:00

(From submission #597.)

Paper P3144R2 (Deleting a Pointer to an Incomplete Type Should be Ill-formed), approved in June, 2024, only covered deletion of incomplete class types. However, enumeration types can also be incomplete per 9.7.1 [dcl.enum] paragraph 6:

An enumeration whose underlying type is fixed is an incomplete type until immediately after its enum-base (if any), at which point it becomes a complete type. An enumeration whose underlying type is not fixed is an incomplete type until the closing } of its enum-specifier , at which point it becomes a complete type.

This leads to the following example that ought to be ill-formed as well:

  enum E {
    zero = decltype(delete static_cast<E*>(nullptr), 0){}
  };
History
Date User Action Args
2024-09-25 17:32:08adminsetmessages: + msg7821
2024-09-25 17:32:08adminsetstatus: open -> nad
2024-08-15 19:36:25adminsetmessages: + msg7792
2024-08-14 00:00:00admincreate