This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.

114. Placement forms example in error twice

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

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 17.6.3.4 [new.delete.placement] with:

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