You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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(deletestatic_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 typeoperand 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 cvvoid is already rejected in [expr.delete] p1 via CWG599.]
The text was updated successfully, but these errors were encountered:
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
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:
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:
[Drafting note: A function pointer or pointer to cv
void
is already rejected in [expr.delete] p1 via CWG599.]The text was updated successfully, but these errors were encountered: