C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relax condition for potentially invoked destructor in constructor

From: organicoman <organicoman_at_[hidden]>
Date: Thu, 24 Feb 2022 19:40:03 +0400
Doh! I meant data members.Wow the proposal examples was so misleading, i was thinking about data members construction after reading the examples then i extrapolated to base classes.Yes, as Jason pointed, base classes initialization order is well defined.But data members of an object, as the proposal points to in its example, can be constructed in different order, at best you will have a compiler warning telling you that you initialized some data member before the other.class PublicInterface {
              std::unique_ptr<class Impl> pimpl_;
          };"pimpl_", is data member not a base class (subobject)Thanks Jason, nice catch, it was lucid 👌 NadirSent from my Galaxy
-------- Original message --------From: Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> Date: 2/24/22 6:41 PM (GMT+04:00) To: std-proposals_at_[hidden] Cc: Jason McKesson <jmckesson_at_[hidden]> Subject: Re: [std-proposals] Relax condition for potentially invoked
  destructor in constructor On Thu, Feb 24, 2022 at 8:22 AM organicoman via Std-Proposals<std-proposals_at_[hidden]> wrote:> But remember that the compiler is free to rearrange the construction of subobjects for optimization purposes,Um, no it isn't. The order of initialization of subobjects iswell-defined ([class.base.init]/13: declaration order, base classesfirst) and not allowed to vary. Compilers are not free to re-orderthose subobject constructors.The OP's point therefore stands: if all of the constructors forsubobjects past a certain point are not potentially throwing, thennone of their destructors *need* to be potentially invoked.That said, I don't think it's a very *useful* idea. It makes"potentially invoked" a matter of exactly how you initialize anobject, which sounds very brittle. One constructor might considercertain destructors to be "potentially invoked" while another may not.And I'm not sure what any of this would actually purchase you in termsof useful functionality.-- Std-Proposals mailing listStd-Proposals_at_[hidden]://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-02-24 15:40:12