This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


2757. Deleting or deallocating storage of an object during its construction

Section: 11.9.5  [class.cdtor]     Status: review     Submitter: Jiang An     Date: 2023-06-14

Subclause 6.7.3 [] paragraph 6 specifies:

... For an object under construction or destruction, see 11.9.5 [class.cdtor]. Otherwise, ...

However, the referenced subclause does not discuss deleting the object or deallocating its storage.

See also issue 2258.

Proposed resolution (reviewed by CWG 2023-10-20):

  1. Insert before 11.9.5 [class.cdtor] paragraph 2 as follows:

    During the initialization or destruction of an object, invoking the destructor for the object or releasing or reusing (6.7.3 []) the storage which the object occupies results in undefined behavior. [ Note: Creating an object nested within some object o does not reuse the storage for o. -- end note ] [ Example:

      struct A() {
        A() {
          ::operator delete(this);
      A *p1 = new A;  // undefined behavior
      struct B() {
        B() {
          delete this;
      B *p2 = new B;  // undefined behavior
      struct S {
        constexpr S() { this->~S(); }
        constexpr S(int) {}
      constexpr int f() {
        S s(0);
        std::construct_at(&s);  // #1
        return 0;
      constexpr int x = f();  // error: undefined behavior at #1

    -- end example ]

    During the construction of an object, if the value of the object ...

  2. Change in 11.9.5 [class.cdtor] paragraph 4 as follows:

    Member functions, including virtual functions (11.7.3 [class.virtual]), other than the destructor can be called during construction or destruction (11.9.3 [class.base.init]). When a virtual function (11.7.3 [class.virtual]) is called directly or indirectly from a constructor or from a destructor, including during the construction or destruction of the class's non-static data members, and ...