diff --git a/abi.html b/abi.html index 2e8dd75..b9eb5ab 100644 --- a/abi.html +++ b/abi.html @@ -2111,86 +2111,114 @@

2.6.4 Construction Virtual Table entries 2.7 Array Operator new Cookies

-When operator new is used to create a new array, -a cookie is usually stored to remember the allocated length -(number of array elements) -so that it can be deallocated correctly. +When a new expression is used to create a new array, +a "cookie" must sometimes be added to the allocation. A cookie is +a header on the array allocation, preceding the array elements, +which stores the number of array elements that were allocated.

-Specifically: +Let T be the element type of the allocated array, +looking through all levels of nested array. +Whether a cookie is required is determined as follows: +

- -

- These rules have the following consequences: -

-
+

If a cookie is required, the allocation is adjusted as follows: +

-Given the above, the following is pseudocode for processing -new(ARGS) T[n]: -

-  if T has a trivial destructor (C++ standard, 12.4/3)
-    padding = 0
-  else if we're using ::operator new[](size_t, void*)
-    padding = 0
-  else
-    padding = max(sizeof(size_t), alignof(T))
-
-  p = operator new[](n * sizeof(T) + padding, ARGS)
-  p1 = (T*) ( (char *)p + padding )
-
-  if padding > 0
-    *( (size_t *)p1 - 1) = n
-
-  for i = [0, n)
-    create a T, using the default constructor, at p1[i]
-
-  return p1
-
+A delete[] expression must also compensate for the +possible presence of an array cookie: +