[new.delete.array]

# 17 Language support library [[support]](./#support)

## 17.6 Dynamic memory management [[support.dynamic]](support.dynamic#new.delete.array)

### 17.6.3 Storage allocation and deallocation [[new.delete]](new.delete#array)

#### 17.6.3.3 Array forms [new.delete.array]

[ð](#lib:new,operator)

`void* operator new[](std::size_t size);
void* operator new[](std::size_t size, std::align_val_t alignment);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2697)

*Effects*: The[allocation functions](basic.stc.dynamic.allocation "6.8.6.5.2 Allocation functions [basic.stc.dynamic.allocation]") called by the array form of a[*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New"))
to allocatesize bytes of storage[.](#1.sentence-1)

The second form is called for a type with new-extended alignment, and
the first form is called otherwise[.](#1.sentence-2)[189](#footnote-189 "It is not the direct responsibility of operator new[] or operator delete[] to note the repetition count or element size of the array. Those operations are performed elsewhere in the array new and delete expressions. The array new expression, can, however, increase the size argument to operator new[] to obtain space to store supplemental information.")

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2725)

*Required behavior*: Same as for
the corresponding single-object forms[.](#2.sentence-1)

This requirement is binding on any replacement versions of these functions[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2731)

*Default behavior*: Returnsoperator new(size),
oroperator new(size, alignment),
respectively[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2739)

*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5 Replaceable function definitions"))[.](#4.sentence-1)

[ð](#lib:new,operator_)

`void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2751)

*Effects*: Same as above, except that these are called by a placement version of a[*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") when a C++ program prefers a null pointer result as an error indication,
instead of abad_alloc exception[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2760)

*Required behavior*: Return a non-null pointer to suitably aligned storage ([[basic.stc.dynamic]](basic.stc.dynamic "6.8.6.5 Dynamic storage duration")),
or else return a null pointer[.](#6.sentence-1)

Each of these nothrow versions ofoperator new[] returns a pointer obtained as if
acquired from the (possibly replaced)
corresponding non-placement function[.](#6.sentence-2)

This requirement is binding on any replacement versions of these functions[.](#6.sentence-3)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2771)

*Default behavior*: Calls operator new[](size),
or operator new[](size, alignment),
respectively[.](#7.sentence-1)

If the call returns normally,
returns the result of that call[.](#7.sentence-2)

Otherwise, returns a null pointer[.](#7.sentence-3)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2780)

*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5 Replaceable function definitions"))[.](#8.sentence-1)

[ð](#lib:delete,operator)

`void operator delete[](void* ptr) noexcept;
void operator delete[](void* ptr, std::size_t size) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2794)

*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new[](std​::​size_t) oroperator new[](std​::​size_t, std​::​align_val_t) which has not been invalidated by an intervening call tooperator delete[][.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2806)

If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#10.sentence-1)

If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#10.sentence-2)

If present, the size argument
is equal to the size argument
passed to the allocation function that returned ptr[.](#10.sentence-3)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2817)

*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3 Deallocation functions"))
called by the array form of a[*delete-expression*](expr.delete#nt:delete-expression "7.6.2.9 Delete [expr.delete]") to render the value of ptr invalid[.](#11.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2825)

*Required behavior*: A call to an operator delete[] with a size parameter
may be changed to
a call to the corresponding operator delete[] without a size parameter,
without affecting memory allocation[.](#12.sentence-1)

[*Note [1](#note-1)*:

A conforming implementation is foroperator delete[](void* ptr, std​::​size_t size) to simply calloperator delete[](ptr)[.](#12.sentence-2)

â *end note*]

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2839)

*Default behavior*: The functions that have a size parameter
forward their other parameters
to the corresponding function without a size parameter[.](#13.sentence-1)

The functions that do not have a size parameter
forward their parameters
to the corresponding operator delete (single-object) function[.](#13.sentence-2)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2848)

*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5 Replaceable function definitions"))[.](#14.sentence-1)

If a replacement function
without a size parameter
is defined by the program,
the program should also define the corresponding
function with a size parameter[.](#14.sentence-2)

If a replacement function
with a size parameter
is defined by the program,
the program shall also define the corresponding
version without the size parameter[.](#14.sentence-3)

[*Note [2](#note-2)*:

The default behavior above might change in the future,
which will require replacing both deallocation functions
when replacing the allocation function[.](#14.sentence-4)

â *end note*]

[ð](#lib:delete,operator_)

`void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
`

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2875)

*Preconditions*: ptr is a null pointer or
its value represents the address of
a block of memory allocated by
an earlier call to a (possibly replaced)operator new[](std​::​size_t) oroperator new[](std​::​size_t, std​::​align_val_t) which has not been invalidated by an intervening call tooperator delete[][.](#15.sentence-1)

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2887)

If the alignment parameter is not present,ptr was returned by an allocation function
without an alignment parameter[.](#16.sentence-1)

If present, the alignment argument
is equal to the alignment argument
passed to the allocation function that returned ptr[.](#16.sentence-2)

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2895)

*Effects*: The
deallocation functions ([[basic.stc.dynamic.deallocation]](basic.stc.dynamic.deallocation "6.8.6.5.3 Deallocation functions"))
called by the implementation
to render the value of ptr invalid
when the constructor invoked from a nothrow
placement version of the array [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") throws an exception[.](#17.sentence-1)

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2904)

*Default behavior*: Calls operator delete[](ptr),
or operator delete[](ptr, alignment),
respectively[.](#18.sentence-1)

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L2910)

*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5 Replaceable function definitions"))[.](#19.sentence-1)

[189)](#footnote-189)[189)](#footnoteref-189)

It is not the direct responsibility ofoperator new[] oroperator delete[] to note the repetition count or element size of the array[.](#footnote-189.sentence-1)

Those operations are performed elsewhere in the arraynew anddelete expressions[.](#footnote-189.sentence-2)

The arraynew expression, can, however, increase the size argument tooperator new[] to obtain space to store supplemental information[.](#footnote-189.sentence-3)
