Created on 2023-06-14.00:00:00 last changed 14 months ago
Proposed resolution (reviewed by CWG 2023-10-20):
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.4 [basic.life]) 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); s.~S(); 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 ...
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 ...
Subclause 6.7.4 [basic.life] 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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-10-20 21:07:14 | admin | set | messages: + msg7470 |
2023-10-20 21:07:14 | admin | set | status: open -> review |
2023-06-14 00:00:00 | admin | create |