Title
Sized deallocation of array of non-class type
Status
cd4
Section
7.6.2.9 [expr.delete]
Submitter
Richard Smith

Created on 2013-09-29.00:00:00 last changed 49 months ago

Messages

Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2014-06-15.00:00:00

Proposed resolution (June, 2014):

Change 7.6.2.9 [expr.delete] paragraph 10 as follows:

If the type is complete and if deallocation function lookup finds both a usual deallocation function with only a pointer parameter and a usual deallocation function with both a pointer parameter and a size parameter, then the selected deallocation function shall be the one with two parameters. Otherwise, the selected deallocation function shall be the function with one parameter. the function to be called is selected as follows:
  • If the type is complete and if, for the second alternative (delete array) only, the operand is a pointer to a class type with a non-trivial destructor or a (possibly multi-dimensional) array thereof, the function with two parameters is selected.

  • Otherwise, it is unspecified which of the two deallocation functions is selected.

Date: 2014-03-03.00:00:00

Additional note, February, 2014:

It is not clear that this resolution accurately reflects the intent of the issue. In particular, it changes deletion of a pointer to incomplete type from requiring use of the single-parameter version to being implementation-defined. Also, the “type of the object to be deleted” in the array case is always an array type and thus cannot be “a complete class type with a non-trivial destructor.” The issue has consequently been returned to "review" status.

Date: 2014-02-15.00:00:00

Proposed resolution (February, 2014) [SUPERSEDED]:

Change 7.6.2.9 [expr.delete] paragraph 10 as follows:

If the type is complete and if deallocation function lookup finds both a usual deallocation function with only a pointer parameter and a usual deallocation function with both a pointer parameter and a size parameter, then

  • for the first alternative (delete object), if the type of the object to be deleted is complete, and for the second alternative (delete array), if the type of the object to be deleted is a complete class type with a non-trivial destructor, then the selected deallocation function shall be the one with two parameters;
  • otherwise, it is implementation-defined which deallocation function is selected.

  • Otherwise, the selected deallocation function shall be the function with one parameter.

Date: 2013-09-29.00:00:00

The changes from N3778 require use of a sized deallocator for a case like

  char *p = new char[32];
  void f() { delete [] p; }

That is unimplementable under current ABIs, which do not store the array size for such allocations. It should instead be unspecified or implementation-defined whether the sized form of operator[] is used for a pointer to a type other than a class with a non-trivial destructor or array thereof.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5345
2014-11-24 00:00:00adminsetstatus: tentatively ready -> dr
2014-07-07 00:00:00adminsetmessages: + msg5075
2014-07-07 00:00:00adminsetstatus: review -> tentatively ready
2014-03-03 00:00:00adminsetmessages: + msg4863
2014-03-03 00:00:00adminsetmessages: + msg4862
2014-03-03 00:00:00adminsetstatus: open -> review
2013-09-29 00:00:00admincreate