220 28023 <57C48794.6020105@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@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: Mon, 29 Aug 2016 15:05:56 -0400
Lines: 47
Approved: news@gmane.org
Message-ID: <57C48794.6020105@gmail.com>
References: <ec2e95cc-3ef0-435b-aaf9-13e982c4583e@isocpp.org>
 <CANh8DEm-3RG1u99c6dUqSgthiVR_wE6FOfzHGbKuMqZBDptcOg@mail.gmail.com>
 <db0b8dd4-5cd9-4d4d-b7a8-95d6ab15ad8c@isocpp.org>
 <4387866d-169e-44a8-a858-d9aa96d54680@isocpp.org>
 <CAE7XuEXEV=xKW_g-1h1MFbg-3Fya83xkcoqGePvPbBPMTXPamA@mail.gmail.com>
 <85dfd0dc-bf1a-4fa8-81f5-2b36e8f6465c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: blaine.gmane.org 1472497567 24176 195.159.176.226 (29 Aug 2016 19:06:07 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 29 Aug 2016 19:06:07 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.1.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBBFUPSK7AKGQEOZZCUPY@isocpp.org Mon Aug 29 21:06:02 2016
Return-path: <std-proposals+bncBC37LBFWUIFBBFUPSK7AKGQEOZZCUPY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBFUPSK7AKGQEOZZCUPY@isocpp.org>)
	id 1beRsc-0005eJ-E2
	for gclcip-std-proposals@m.gmane.org; Mon, 29 Aug 2016 21:05:58 +0200
Original-Received: by mail-ua0-f198.google.com with SMTP id m60sf322697781uam.3
        for <gclcip-std-proposals@m.gmane.org>; Mon, 29 Aug 2016 12:05:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:reply-to:message-id:date:user-agent
         :mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=Q3yKxnA3YFgIwFgICluN3dyJVbB48cuWybMZYz7+7xk=;
        b=EJLWO+itELpZyWkv9I78+CkhtnWMRbzSNqQlO6yVzDiz2wFJK9M4gHJPrWYRJsNxQJ
         O6NLSVE1b91BXwv2GFYBtoamz0sv3j8/aEFyBaahhhC4a0m4uign3qgwGK8+6wztjWKo
         hiFlycqBAef3lJ1RfMIkhxDvt7J+ESv+8jkKgYQ7NDRDzEJeM31J+KSF6gUvZr0Qu36o
         WC+k6wDEKfj5AXAhWJD2iqGhgqiDP2uw9tRgmvtXYh3tXeM289+CcnhaOV55b6TSpOWQ
         Wg6VdJFOBOpIQX9XmtIFWhu3fUnLFXDz+hUcSLgQOZHTYbQ5my0gE2L+oNz2Fu9//0EJ
         M9zA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:reply-to:message-id
         :date:user-agent:mime-version:in-reply-to:x-original-sender
         :x-original-authentication-results:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=Q3yKxnA3YFgIwFgICluN3dyJVbB48cuWybMZYz7+7xk=;
        b=X4C2MUuhh4WzHqXzMQ3WRY+7uPXonqPWIjSOEPEpkEeBw5zAXxmxMAuFE7E56hkk6Z
         NhwCRr5aZRUBhFFY4gdcShDfQU8GbNWBJeZ5rY8pnPvQItdhUl8fDo3p+NgMCxn2E15v
         NHdNWqk0Ji8TsznBFApodbwOBrUf9NbCR+afrjnyhU+Dl/mV+/hxFbxZord8HgxOhb3s
         V9aSPwXKEE7DRlPgBrlIQIzdwUA2pQkjUevrz0LTME4adkgm+OvzypqkUGCIEISLgt87
         DTrbS1MiZkVP3vuiebpv8namxUaD5YPjGlGOQ5L5ifZMJwjG17SLte8RlXt8H0L5aENU
         ho5Q==
X-Gm-Message-State: AE9vXwP8yJGfEyt1o82jVIPPH7nTvjlX4V7sciH8mObSxtQU184HFas0oxKFpw9dIpomjg==
X-Received: by 10.129.82.86 with SMTP id g83mr14569217ywb.14.1472497559091;
        Mon, 29 Aug 2016 12:05:59 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.24.71 with SMTP id t7ls8778687ott.5.gmail; Mon, 29 Aug
 2016 12:05:58 -0700 (PDT)
X-Received: by 10.237.44.66 with SMTP id f60mr20634387qtd.11.1472497558181;
        Mon, 29 Aug 2016 12:05:58 -0700 (PDT)
Original-Received: from mail-qt0-x235.google.com (mail-qt0-x235.google.com. [2607:f8b0:400d:c0d::235])
        by mx.google.com with ESMTPS id n13si24352749qta.15.2016.08.29.12.05.58
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 29 Aug 2016 12:05:58 -0700 (PDT)
Received-SPF: pass (google.com: domain of mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c0d::235 as permitted sender) client-ip=2607:f8b0:400d:c0d::235;
Original-Received: by mail-qt0-x235.google.com with SMTP id u25so73236129qtb.1
        for <std-proposals@isocpp.org>; Mon, 29 Aug 2016 12:05:58 -0700 (PDT)
X-Received: by 10.200.36.83 with SMTP id d19mr20545413qtd.94.1472497557772;
        Mon, 29 Aug 2016 12:05:57 -0700 (PDT)
Original-Received: from [192.168.1.173] (tripoint.kitware.com. [66.194.253.20])
        by smtp.googlemail.com with ESMTPSA id j67sm19313340qkd.26.2016.08.29.12.05.56
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 29 Aug 2016 12:05:57 -0700 (PDT)
X-Enigmail-Draft-Status: N1110
In-Reply-To: <85dfd0dc-bf1a-4fa8-81f5-2b36e8f6465c@isocpp.org>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 mwoehlke.floss@gmail.com designates 2607:f8b0:400d:c0d::235 as permitted
 sender) smtp.mailfrom=mwoehlke.floss@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=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:28023
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28023>

On 2016-08-29 14:46, Nicol Bolas wrote:
> This problem is fundamentally identical to the temporary lifetime extension 
> problem. Namely, that this works:
> 
> const auto &str = std::string(...);
> //use str
> 
> While this does not:
> 
> const auto &str = std::string(...).c_str();
> //use str

I think having explicit temporary types might help here:

  std::string::c_str() -> char const* register; // declaration

  // error: taking reference of register-qualified type.
  const auto &str = std::string(...).c_str();

Obviously, it is too late to change std::string this way, but it would
help us write better API's going forward. Specifically:

> The compiler does not and *cannot* know, in all cases, whether a 
> return value of a function contains a pointer/reference to an 
> argument or an element of an argument.

....it would be a way to solve this.

On 2016-08-29 14:52, Nicol Bolas wrote:
> So now you want `const virtual register` qualifiers on variables? Do we 
> *really* need that?

Well... *yes*. For exactly the reason given above. Making it a qualifier
makes it possible to actually *solve* some of these problems, at least
by making them explicitly ill-formed rather than just subtly broken.

Mind, this idea isn't fully baked, but it might (*might*) have potential...

-- 
Matthew

-- 
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/57C48794.6020105%40gmail.com.

.
