Title
Determining the buffer size for placement new
Status
cd5
Section
7.6.2.8 [expr.new]
Submitter
Ben Hutchings

Created on 2004-09-14.00:00:00 last changed 23 months ago

Messages

Date: 2019-11-15.00:00:00

Additional note (November, 2019):

The resolution of issue 2382 effectively addresses the request in this issue by eliminating the array overhead in the case of the standard placement allocator.

EWG (January, 2021):

Resolved by issue 2382. See vote.

Date: 2012-02-15.00:00:00

Rationale (February, 2012):

The CWG agreed that EWG is the appropriate venue for dealing with this issue.

Date: 2022-11-20.07:54:16

Note, January, 2012:

It has been suggested that this issue is more appropriate for EWG and should thus be closed with "extension" status.

Date: 2005-04-15.00:00:00

Notes from the April, 2005 meeting:

While the CWG agreed that there is no portable means to accomplish this task in the current language, they felt that a paper is needed to analyze the numerous mechanisms that might address the problem and advance a specific proposal. There is no volunteer to write such a paper at this time.

Date: 2019-11-15.00:00:00

[Resolved by issue 2382, which was accepted as a DR at the November, 2019 meeting.]

(See also issue 256.)

An implementation may have an unspecified amount of array allocation overhead (7.6.2.8 [expr.new] paragraph 10), so that evaluation of a new-expression in which the new-type-id is T[n] involves a request for more than n * sizeof(T) bytes of storage through the relevant operator new[] function.

The placement operator new[] function does not and cannot check whether the requested size is less than or equal to the size of the provided region of memory (17.6.3.4 [new.delete.placement] paragraphs 5-6). A program using placement array new must calculate what the requested size will be in advance.

Therefore any program using placement array new must take into account the implementation's array allocation overhead, which cannot be obtained or calculated by any portable means.

History
Date User Action Args
2022-04-27 22:14:34adminsetstatus: extension -> cd5
2020-12-15 00:00:00adminsetmessages: + msg6318
2012-02-27 00:00:00adminsetmessages: + msg3862
2012-02-27 00:00:00adminsetstatus: open -> extension
2012-01-17 00:00:00adminsetmessages: + msg3622
2005-05-01 00:00:00adminsetmessages: + msg1173
2004-09-14 00:00:00admincreate