Title
Placement forms example in error twice
Status
tc1
Section
[new.delete.placement]
Submitter
Steve Clamage

Created on 1998-10-28.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

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

void* place = operator new(sizeof(Something));
Date: 1998-10-28.00:00:00

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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg892
1998-10-28 00:00:00admincreate