C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Behavior of implicitly defined destructor unspecified?
From: Andrew Schepler (aschepler_at_[hidden])
Date: 2019-12-13 07:09:09


I agree that wording does seem to be missing (though the correct behavior
is "obvious" in practice). And that the default constructor wording might
make a good model for a fix:

"The implicitly-defined destructor performs the subobject destructor calls
that would be performed by a user-written destructor for the class with an
empty compound-statement. If that user-written destructor would be
ill-formed, the program is ill-formed."

That would normally fit between [class.dtor] paragraphs 10 (when implicit
definition happens) and 11 (prerequisite subobject destructor implicit
definitions). Their counterparts often aren't in separate paragraphs,
though. Also probably paragraph 9 about constexpr defaulted destructors
should be reworded and moved immediately after the above insertion:

"If that user-written destructor would satisfy the requirements of a
constexpr destructor ([dcl.constexpr]), the implicitly defined destructor
is constexpr."

-- Andrew Schepler

On Thu, Dec 12, 2019 at 9:54 AM Stephan Bergmann via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> There appears to be no description of the behavior of an implicitly
> defined destructor (in neither C++17 nor the current draft).
> [class.dtor]/4 says: "After executing the body of the destructor [...]",
> but I can't find mention of what the body of an implicitly defined
> destructor should look like. Something like "For an implicitly defined
> destructor, the body is empty" seems to be missing.
>
> (For example for an implicitly defined default constructor,
> [class.ctor]/7 says: "The implicitly-defined default constructor
> performs the set of initializations [...]")
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>



STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups