114. Placement forms example in error twice

Section: 21.6.2.3 [new.delete.placement] Status: TC1 Submitter: Steve Clamage Opened: 1998-10-28 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [new.delete.placement].

View all issues with TC1 status.

Duplicate of: 196

Discussion:

Section 18.5.1.3 contains the following example:

[Example: This can be useful for constructing an object at a known address:
        char place[sizeof(Something)];
        Something* p = new (place) Something();
 -end example]

First code line: "place" need not have any special alignment, and the following constructor could fail due to misaligned data.

Second code line: Aren't the parens on Something() incorrect?  [Dublin: the LWG believes the () are correct.]

Examples are not normative, but nevertheless should not show code that is invalid or likely to fail.

Proposed resolution:

Replace the first line of code in the example in 21.6.2.3 [new.delete.placement] with:

void* place = operator new(sizeof(Something));