C++ Logo


Advanced search

[std-proposals] Make calling the pseudo-destructor multiple times on an object undefined behavior?

From: blacktea hamburger <blackteahamburger_at_[hidden]>
Date: Sun, 28 Aug 2022 13:06:06 +0000
Calling the destructor multiple times on a class object results in undefined behavior according to [class.dtor]/19<https://eel.is/c++draft/class.dtor#19>:

Once a destructor is invoked for an object, the object's lifetime ends; the behavior is undefined if the destructor is invoked for an object whose lifetime has ended ([basic.life]).

However, similar thing doesn't apply to pseudo-destructor calls.

P0593R6<https://wg21.link/P0593R6> makes pseudo-destructor calls end objects' lifetimes. I wonder if adding such a provision would be useful.

Received on 2022-08-28 13:06:11