Reopen A-20/A-21?

Mark Mitchell mark at codesourcery.com
Thu Mar 2 09:27:34 UTC 2000


I believe the resolution to A-20/A-21, dealing with array new, is
incorrect with respect to the C++ standard.  (In other words, I think
we'll make it impossible to implement the behavior required by the
standard.)

In particular, there are situations in which we do not allocate
cookies, even when allocating arrays of class type.

But, the standard guarantees that:

  [class.free]

  When  a delete-expression is executed, the selected deallocation func-
  tion shall be called with the address of the block of  storage  to  be
  reclaimed  as  its  first  argument and (if the two-parameter style is
  used) the size of the block as its second argument.3)

That paragraph doesn't require that the class type have a non-trivial
destructor.

I think that means the first bullet:

  No cookie is required if the array element type T has a trivial
  destructor (C++ standard, 12.4/3).

should read:

  No cookie is required if the array element type T has a trivial
  destructor ([class.dtor]) and the usual (array) deallocation
  function ([basic.stc.dynamic.deallocation]) function does not take 
  two arguments.

  (Note: if the usual array deallocation functions takes two
  arguments, then its second argument is of type size_t.  The standard
  guarantees that this function will be passed the number of bytes
  allocated with the previous array new expression.  See [class.free]
  for details.)

Let's either prove me wrong, or accept this resolution, tomorrow.  It
shouldn't take long either way.

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list