Title
Incorrect use of placement new in example
Status
c++11
Section
6.7.3 [basic.life]
Submitter
GB

Created on 2010-08-02.00:00:00 last changed 96 months ago

Messages

Date: 2010-11-15.00:00:00

[Voted into the WP at the November, 2010 meeting.]

Date: 2010-08-15.00:00:00

Proposed resolution (August, 2010):

Change the example in 6.7.3 [basic.life] paragraph 9 as follows:

    ...
    new (const_cast<B *>(&b)) const B;  // undefined behavior
    ...
Date: 2010-08-02.00:00:00
N3092 comment GB 18

The example in 6.7.3 [basic.life] paragraph 9 reads,

    struct B {
      B();
      ~B();
    };

    const B b;

    void h() {
      b.~B();
      new (&b) const B;  // undefined behavior
    }

Assuming that the placement new is intended to use the operator defined in the Standard library, the new-expression is ill-formed, because there is no implicit conversion from “pointer to const B” to void*.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: dr -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3147
2010-11-29 00:00:00adminsetstatus: ready -> dr
2010-08-23 00:00:00adminsetmessages: + msg2763
2010-08-02 00:00:00admincreate