Skip to content

CWG2925 [expr.delete] Deleting a pointer to an incomplete enumeration type should also be ill-formed #597

Description

@frederick-vs-ja

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [expr.delete]

Link to reflector thread (if any):

Issue description:

Paper P3144R2 only made deleting a pointer of pointer to incomplete class type ill-formed, which didn't match its title (Deleting a Pointer to an Incomplete Type Should be Ill-formed), since it's possible to form a delete-expression whose operand is of poiner to incomplete enumeration type.

A counterexample can be:

enum e { zero = decltype(delete static_cast<e*>(nullptr), 0){} };

which is currently rejected by Clang since C++26 mode (Godbolt link).

Note that UB can never be raised from such a delete-expression, because the enumerator must be a constant. However, given such delete-expressions are weird and useless, and there's already an implementation rejecting them, it may be better to make them ill-formed.

Also "the object being deleted" in the current wording is a bit unclear, because the value of the operand still seems to matter after P3144R2, while the intent is probably that only the type of the operand is concerned.

Suggested resolution:

Change [expr.delete] p4 as indicated:

If the object being deleted has incomplete class type operand is of type “pointer to incompletely-defined object type” at the point of deletion, the program is ill-formed.

[Drafting note: A function pointer or pointer to cv void is already rejected in [expr.delete] p1 via CWG599.]

Activity

  1. jensmaurer commented on Aug 15, 2024

    @jensmaurer
    Member
  2. changed the title [-][expr.delete] Deleting a pointer to an incomplete enumeration type should also be ill-formed[/-] [+]CWG2925 [expr.delete] Deleting a pointer to an incomplete enumeration type should also be ill-formed[/+] on Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions