Open vasama opened 2 months ago
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.
CWG2889
This resolution would also resolve CWG2880.
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.
Full name of submitter: Lauri Vasama
Reference: [expr.delete]
Issue description:
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:
Related LLVM issue: https://github.com/llvm/llvm-project/issues/46818