Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13


1114. Incorrect use of placementnew in example

Section:6.7.4  [basic.life]    Status:C++11    Submitter:GB    Date:2010-08-02

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

N3092 comment GB 18

The example in 6.7.4 [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 placementnew is intended to usethe operator defined in the Standard library, thenew-expressionis ill-formed, because there is no implicit conversion from“pointer to constB” tovoid*.

Proposed resolution (August, 2010):

Change the example in 6.7.4 [basic.life] paragraph 9 asfollows:

    ...    new (const_cast<B *>(&b)) const B;  // undefined behavior    ...



[8]ページ先頭

©2009-2025 Movatter.jp