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

2024-12-19


2258. Storage deallocation during period of destruction

Section: 6.7.4  [basic.life]     Status: open     Submitter: Richard Smith     Date: 2016-04-12

What happens if the storage for an object is deallocated in its period of destruction? Consider:

  struct Base {
    virtual ~Base() {
      ::operator delete(this);
    }
    void operator delete(void*) {}
  };

  struct Derived : Base {};

  int main() {
    delete new Derived;
  } 

This ought to be undefined behavior, but the standard is silent on the matter.

Notes from the December, 2016 teleconference:

The consensus view was that this should be undefined behavior.

Additional notes (July, 2023)

This issue is a subset of issue 2757.