220 27916 <5c7c5507-698d-460c-bed2-88adb07ebc07@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Specifier to cause the destructor to be called at
 last use instead of end of scope
Date: Wed, 24 Aug 2016 12:17:46 -0700 (PDT)
Lines: 83
Approved: news@gmane.org
Message-ID: <5c7c5507-698d-460c-bed2-88adb07ebc07@isocpp.org>
References: <ec2e95cc-3ef0-435b-aaf9-13e982c4583e@isocpp.org>
 <CAPzzLY=xcAv2DCwmqZHwv5hkbFsdXOEGUsNdw7G83J=jn3m2TQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_73_941638373.1472066266965"
X-Trace: blaine.gmane.org 1472066274 31753 195.159.176.226 (24 Aug 2016 19:17:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 24 Aug 2016 19:17:54 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBXHF666QKGQEI6PRVEA@isocpp.org Wed Aug 24 21:17:50 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBXHF666QKGQEI6PRVEA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f69.google.com ([209.85.220.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBXHF666QKGQEI6PRVEA@isocpp.org>)
	id 1bcdgK-0007dA-EP
	for gclcip-std-proposals@m.gmane.org; Wed, 24 Aug 2016 21:17:48 +0200
Original-Received: by mail-pa0-f69.google.com with SMTP id ag5sf42570235pad.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 24 Aug 2016 12:17:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=NbLNcgcYGILmXLnnuuWeitjXaiD0Nl7wKSgnE/+XnD4=;
        b=C6sZZfBuwbC5SeI1/iMCg/Es8+rRH6HSSNbd4VCARsjnkyFf39hrIXnplUYJ2cJVW8
         1/u6yFQFaaFsXNSp6wwcP35MB46PKIiEzDZNJJqgeKiBo8FakQu7RQZ8QTAulvdjz41V
         4OsjFiZtZdEUyLDlVIT7kUNjgWwyZAYD/H0tQVbusafakn38mN0+ogdIlg7RwMf3nfKb
         vV/0kGNd5JeGNenUUTY3593xM4rIsFwUp35ApehHpNzbIrHRU0ADwpyelMUS5aszPVGb
         feyTrkB9K5kSmDEOaAIPtaTyFrvctZoV6rakhOjkFNxaoyNtpaqp3X6b8T39fRsqLSps
         bKFA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=NbLNcgcYGILmXLnnuuWeitjXaiD0Nl7wKSgnE/+XnD4=;
        b=xhs+2Nu1VVuAk+nfP+P4WLDDzIXjVBM+1wvpwEhJtBYHDRt8a4xflcQkzqwQABBc+V
         9RRTom3m5WqYYneDsbwYqSdFX5AGRRbVFEc9A9dRXBeigO6Ycv+D6QyIYZWTvIOLsMd4
         +XDHbjh0RuPWNlnCmigzMada4de7A8B6GfO60f2Ik7HTKezn5xO/vHVjPPbKNQOrJ4Dw
         LFAx4QNvATnlybbU1vVpi0CYqdFFtdelRN5vRgkEkx5PeQBkEfg840iWiDSmflubBnaS
         0DaeVdBWTLVeIy9+XJO7QzpldiyrBazIm4jSsE8G6dNIFdmoYb/P4eDmkP6ACIS2g/PI
         iYrw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=NbLNcgcYGILmXLnnuuWeitjXaiD0Nl7wKSgnE/+XnD4=;
        b=e8BZ2j7tQ4ZEyHw3d7BVFxDBZB99/9qE5Vp4SlNFcJEI8w0YMom1n7Be4VOIu/eazk
         RyzG5fn9JIYgz655w5Zai/1qogVOkwt5yfwqXMIUdyDsFWDTWz9hCLMDTA5up1eHQFBk
         4rpxtGfqXHGj/9cKqxsujoGJthREWah3GJ6C9xHEYTJlmz1Dd9MN/wT8s+WrYjwZk/yE
         rgC4okFRv5/ZUPIfRnRL2Lt4X+8JuDSTuHHhP9n6Q2H5mGu9yAQVDFCEboYnNpGvajyw
         sYvtHWBCNYQHLtu8t9QhQkSsu0W+PY9/ktdXjnTFY8hTOP6G5toGchpxjGmQVNPXiT/+
         TXcg==
X-Gm-Message-State: AE9vXwN/bYga0+0kdhg6hpvv0rtyfuG1JUgK0rVr3J/AuJempTEh+SXzKfKI0HxZVfARHQ==
X-Received: by 10.98.20.196 with SMTP id 187mr3221619pfu.0.1472066268890;
        Wed, 24 Aug 2016 12:17:48 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.47.205 with SMTP id j196ls1272206itj.17.gmail; Wed, 24 Aug
 2016 12:17:47 -0700 (PDT)
X-Received: by 10.36.36.10 with SMTP id f10mr51023ita.7.1472066267966;
        Wed, 24 Aug 2016 12:17:47 -0700 (PDT)
In-Reply-To: <CAPzzLY=xcAv2DCwmqZHwv5hkbFsdXOEGUsNdw7G83J=jn3m2TQ@mail.gmail.com>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:27916
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27916>

------=_Part_73_941638373.1472066266965
Content-Type: multipart/alternative; 
	boundary="----=_Part_74_110875447.1472066266965"

------=_Part_74_110875447.1472066266965
Content-Type: text/plain; charset=UTF-8

On Wednesday, August 24, 2016 at 3:10:04 PM UTC-4, Pablo Oliva wrote:
>
> I don't quite get why simply calling the normal destructor for the object 
> wouldn't achieve the optimization goals you pretend.
>

Because that would provoke UB. If you explicitly call the destructor for an 
automatic object, the system will still call the destructor at the end of 
scope. Unless you reconstructed the object in that memory beforehand, you 
will get UB.

What you seem to be suggesting is that we can signal the complier that an 
> object should be destroyed as soon as possible. This seems to be more of a 
> quality of implementation issue on the compiler's side than something that 
> needs to be standardized. And it doesn't need a different destructor.
>

The destructor for a non-trivially destructible automatic object is called 
at the end of scope, and will be called in the reverse order of 
construction. As such, the side-effects *cannot* happen before the end of 
scope. So there's no QOI here; the standard does not permit a non-trivially 
destructible automatic object to be destroyed before the end of scope or 
out-of-order. 

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5c7c5507-698d-460c-bed2-88adb07ebc07%40isocpp.org.

------=_Part_74_110875447.1472066266965
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, August 24, 2016 at 3:10:04 PM UTC-4, Pablo O=
liva wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">I =
don&#39;t quite get why simply calling the normal destructor for the object=
 wouldn&#39;t achieve the optimization goals you pretend.</div></blockquote=
><div><br>Because that would provoke UB. If you explicitly call the destruc=
tor for an automatic object, the system will still call the destructor at t=
he end of scope. Unless you reconstructed the object in that memory beforeh=
and, you will get UB.<br><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div></div><div>What you seem to be suggesting is th=
at we can signal the complier that an object should be destroyed as soon as=
 possible. This seems to be more of a quality of implementation issue on th=
e compiler&#39;s side than something that needs to be standardized. And it =
doesn&#39;t need a different destructor.</div></div></blockquote><div><br>T=
he destructor for a non-trivially destructible automatic object is called a=
t the end of scope, and will be called in the reverse order of construction=
.. As such, the side-effects <i>cannot</i> happen before the end of scope. S=
o there&#39;s no QOI here; the standard does not permit a non-trivially des=
tructible automatic object to be destroyed before the end of scope or out-o=
f-order. <br></div><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5c7c5507-698d-460c-bed2-88adb07ebc07%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5c7c5507-698d-460c-bed2-88adb07ebc07=
%40isocpp.org</a>.<br />

------=_Part_74_110875447.1472066266965--

------=_Part_73_941638373.1472066266965--

.
