Skip to content

CWG2889 [expr.delete] use of destroying delete requires accessible destructor #532

Description

@vasama

Full name of submitter: Lauri Vasama

Reference: [expr.delete]

Issue description:

If the value of the operand of the delete-expression is not a null pointer value and the selected deallocation function (see below) is not a destroying operator delete, evaluating the delete-expression invokes the destructor (if any) for the object or the elements of the array being deleted. The destructor shall be accessible from the point where the delete-expression appears.

The second sentence is not conditional on whether the selected deallocation function is a destroying operator delete, though it surely should be.

Suggested resolution:

Modify the sentence as follows:

If invoked, the destructor shall be accessible from the point where the delete-expression appears.

Related LLVM issue: llvm/llvm-project#46818

Activity

  1. t3nsor commented on May 6, 2024

    @t3nsor

    If invoked, the destructor shall be accessible ...

    Whether or not it's invoked depends on whether the pointer is null, which isn't known at compile time.

    I think what we want to say is something like this:

    If the type of the operand of the delete-expression is a pointer to a class type or (possibly multidimensional) array thereof, and the selected deallocation function (see below) is not a destroying operator delete:

    • The destructor is potentially invoked ([class.dtor]).
    • If the pointer value is not null, evaluating a single-object delete expression destroys the object pointed to by the operand, and evaluating an array delete expression destroys each element of the array pointed to by the operand in order of decreasing index.
  2. jensmaurer commented on May 6, 2024

    @jensmaurer
    Member
  3. changed the title [-][expr.delete] use of destroying delete requires accessible destructor[/-] [+]CWG2889 [expr.delete] use of destroying delete requires accessible destructor[/+] on May 6, 2024
  4. t3nsor commented on May 30, 2024

    @t3nsor

    This resolution would also resolve CWG2880.

  5. t3nsor commented on May 31, 2024

    @t3nsor

    Wait, sorry, I take back my previous comment. But it would actually make sense to try to fold the resolution of 2880 into this one.

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