-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Migrating from https://isocpp.org/files/papers/P1018R18.html#issues
CWG1915
Section: 11.9.3 [class.base.init] Status: extension Submitter: Aaron Ballman Date: 2014-04-15
The requirement in 11.9.3 [class.base.init] paragraph 10,
In a non-delegating constructor, the destructor for each potentially constructed subobject of class type is potentially invoked (11.4.7 [class.dtor]). [Note: This provision ensures that destructors can be called for fully-constructed sub-objects in case an exception is thrown (14.3 [except.ctor]). —end note]
is needlessly restrictive, preventing otherwise-reasonable code like
class Base {
protected:
Base(int i) noexcept {}
Base() = delete;
~Base() = delete;
};
class Derived : public Base {
public:
Derived() noexcept : Base(1) {}
~Derived() = delete;
};
Since the derived class constructor is non-throwing, the deleted base class destructor need not be referenced.
Suggested resolution:
Change 11.9.3 [class.base.init] paragraph 10 as follows:
In a non-delegating constructor without a non-throwing exception-specification (14.5 [except.spec]), the destructor for each potentially constructed subobject of class type is potentially invoked (11.4.7 [class.dtor]). [Note: This provision ensures that destructors can be called for fully-constructed sub-objects in case an exception is thrown (14.3 [except.ctor]) but does not prevent explicitly deleted destructors in the presence of a non-throwing constructor. —end note]
Rationale (June, 2014):
This request for a language change should be evaluated by EWG before any action is taken.
Meeting: (notes 2020-04-23) the proposed wording changes the implementation leeway in two-phase unwinding, which breaks some existing ABIs. We would need a paper to explore this further. Suggest closing as Not A Defect. No objection to unanimous consent.
Discussed in Kona, needs a paper.