This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1788. Sized deallocation of array of non-class type

Section: 7.6.2.9  [expr.delete]     Status: CD4     Submitter: Richard Smith     Date: 2013-09-29

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

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.

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

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.

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: