220 31112 <CAGsORuD=UDBc7MPKcbyH7p4B-EpN8guiw9kOQHHOTmi+=gEqzQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Zhihao Yuan <zy@miator.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: P0577: No lifetime extension for xvalue .
Date: Fri, 24 Feb 2017 11:46:02 -0600
Lines: 40
Approved: news@gmane.org
Message-ID: <CAGsORuD=UDBc7MPKcbyH7p4B-EpN8guiw9kOQHHOTmi+=gEqzQ@mail.gmail.com>
References: <e1dd36c5-58c4-4f20-870f-d806158b1187@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 1487958368 13977 195.159.176.226 (24 Feb 2017 17:46:08 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 24 Feb 2017 17:46:08 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCSKRWMD4EHBBXXCYHCQKGQEDVYXCPA@isocpp.org Fri Feb 24 18:46:04 2017
Return-path: <std-proposals+bncBCSKRWMD4EHBBXXCYHCQKGQEDVYXCPA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCSKRWMD4EHBBXXCYHCQKGQEDVYXCPA@isocpp.org>)
	id 1chJwP-0002yd-P0
	for gclcip-std-proposals@m.gmane.org; Fri, 24 Feb 2017 18:46:01 +0100
Original-Received: by mail-oi0-f70.google.com with SMTP id q66sf3031082oib.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Feb 2017 09:46:07 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:sender:mime-version:in-reply-to:references:from
         :date:message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=gVes6Xu4Vgu3LTFhDzOo/RLr3CH/4A/ysTJUNNOzyCg=;
        b=sQcW1g8ZAIxHSuQmNjNEidK2khNLDJsPnbTzWblcFN668H6C8T4NDx8X7eLdxPIs4O
         eWKhKWlK1CxHQeW+Kf0LH8ddvVVkaqLAwVbn4W4WRLK8qpHUDP9Bg5ASpDECMJgq4icD
         LHLxxLLKbGNOT2ikxobkeoMOBC5bwOGqScVxQTW+ZKjM/Y/zH2lT5+C2OeQEVIgIszr4
         Zig8j/K30oDfqcXN0rmpyK9pzrNvxwzvcr9oLhLJr64hOFbi+lks7H3SnqIRyaBLdFN5
         fcUN+tHj6ROIr87AvR8O92R5Lj7kuZtO6HT/0wuBH2EkolZ2JYk8JDWo5JTfGCC8i8eE
         nBXw==
X-Gm-Message-State: AMke39k9utpdYTUnDjRPgqkOyvrq9OR1m9rM2TorO17YQQgtYnpXaLu1iP1qnaj53W3w4Q==
X-Received: by 10.107.47.168 with SMTP id v40mr1512650iov.97.1487958367347;
        Fri, 24 Feb 2017 09:46:07 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.3.235 with SMTP id f98ls2550074otf.16.gmail; Fri, 24 Feb
 2017 09:46:06 -0800 (PST)
X-Received: by 10.237.53.177 with SMTP id c46mr4290731qte.124.1487958366567;
        Fri, 24 Feb 2017 09:46:06 -0800 (PST)
Original-Received: from mail-s68.mailgun.info (mail-s68.mailgun.info. [184.173.153.196])
        by mx.google.com with ESMTPS id p3si1013331qtc.154.2017.02.24.09.46.06
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 24 Feb 2017 09:46:06 -0800 (PST)
Received-SPF: pass (google.com: domain of bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates 184.173.153.196 as permitted sender) client-ip=184.173.153.196;
Original-Sender: zy@miator.net
X-Mailgun-Sending-Ip: 184.173.153.196
X-Mailgun-Sid: WyI3MTBkYiIsICJzdGQtcHJvcG9zYWxzQGlzb2NwcC5vcmciLCAiNjkxMTAiXQ==
Original-Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181])
 by mxa.mailgun.org with ESMTP id 58b0715c.7fcc880d0d30-smtp-out-n03;
 Fri, 24 Feb 2017 17:46:04 -0000 (UTC)
Original-Received: by mail-wr0-f181.google.com with SMTP id u47so17809944wrb.0
        for <std-proposals@isocpp.org>; Fri, 24 Feb 2017 09:46:04 -0800 (PST)
X-Received: by 10.223.133.205 with SMTP id 13mr3986775wru.1.1487958363041;
 Fri, 24 Feb 2017 09:46:03 -0800 (PST)
Original-Received: by 10.80.173.212 with HTTP; Fri, 24 Feb 2017 09:46:02 -0800 (PST)
In-Reply-To: <e1dd36c5-58c4-4f20-870f-d806158b1187@isocpp.org>
X-Gmail-Original-Message-ID: <CAGsORuD=UDBc7MPKcbyH7p4B-EpN8guiw9kOQHHOTmi+=gEqzQ@mail.gmail.com>
X-Original-Sender: zy@miator.net
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@miator.net;       spf=pass (google.com: domain of
 bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates
 184.173.153.196 as permitted sender) smtp.mailfrom=bounce+3f9131.69110-std-proposals=isocpp.org@miator.net
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:31112
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31112>

On Fri, Feb 24, 2017 at 8:48 AM, Nicol Bolas <jmckesson@gmail.com> wrote:
> auto &&r2 = X().n;
>
> For `r1`, if `f` returns an rvalue reference that refers to its parameter or
> a subobject thereof, this will be a dangling reference.
>
> But `r2` is perfectly fine. The lifetime of the prvalue temporary will be
> extended even though we are not actually referencing it directly.
> [class.temporary]p6:
>
> [...]
>
> The idea of lifetime extension should not be that you provide lifetime
> extension for all xvalues. But it also shouldn't be that you provide
> lifetime extension for prvalues. It should be that you provide lifetime
> extension for any expression for which lifetime extension is currently
> valid. It should behave exactly as if you had created a reference variable
> with that expression.

I think we can find some compromise here, that is to extend
lifetime for certain xvalues that we can, but not change any
xvalue's value category, making it useful to interfaces
which do not care about value categories, and still safe in
general.  Example:

  struct X { std::string s; };
  string_view x = __extend_me X().s;  // fine, extending s

-- 
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/

-- 
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/CAGsORuD%3DUDBc7MPKcbyH7p4B-EpN8guiw9kOQHHOTmi%2B%3DgEqzQ%40mail.gmail.com.

.
