Content-Length: 202464 | pFad | https://github.com/cplusplus/CWG/issues/597

01 CWG2925 [expr.delete] Deleting a pointer to an incomplete enumeration type should also be ill-formed · Issue #597 · cplusplus/CWG · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
frederick-vs-ja opened this issue Aug 14, 2024 · 1 comment

Comments

@frederick-vs-ja
Copy link

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.]

@jensmaurer
Copy link
Member

CWG2925

@jensmaurer jensmaurer 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 Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/cplusplus/CWG/issues/597

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy