Created on 2024-08-14.00:00:00 last changed 1 month ago
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.
Suggested resolution:
Change in 7.6.2.9 [expr.delete] paragraph 4 as follows:
If the static type of the objectbeingto be deleted has incompleteclasstype at the point of deletion, the program is ill-formed.
(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:08 | admin | set | messages: + msg7821 |
2024-09-25 17:32:08 | admin | set | status: open -> nad |
2024-08-15 19:36:25 | admin | set | messages: + msg7792 |
2024-08-14 00:00:00 | admin | create |