220 36478 <CADvuK0LhJMe01RiTW5M52A9WwsG4wzHrgcHiT5jXN59Gyoh6AQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Treating local variables as rvalues in return statements
Date: Wed, 3 Jan 2018 11:05:10 -0800
Lines: 128
Approved: news@gmane.org
Message-ID: <CADvuK0LhJMe01RiTW5M52A9WwsG4wzHrgcHiT5jXN59Gyoh6AQ@mail.gmail.com>
References: <4ff5fe2d-0945-491f-9888-479b8e866ace@isocpp.org>
 <1823126.nxGvHgdJMA@tjmaciei-mobl1> <CAA7U3HPMh9VHo_16djyzT0KnzVf+ab0Nm2CoU7zFfKJqCyfJ3w@mail.gmail.com>
 <3356554.N1GgDjyayG@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="f403045c28b8fa3ae30561e3e423"
X-Trace: blaine.gmane.org 1515006204 17119 195.159.176.226 (3 Jan 2018 19:03:24 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 3 Jan 2018 19:03:24 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIOPUVU2ICRUBEGDPWJY@isocpp.org Wed Jan 03 20:03:19 2018
Return-path: <std-proposals+bncBDLZJYWNDQIOPUVU2ICRUBEGDPWJY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f200.google.com ([209.85.128.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIOPUVU2ICRUBEGDPWJY@isocpp.org>)
	id 1eWoJh-0003XJ-K6
	for gclcip-std-proposals@m.gmane.org; Wed, 03 Jan 2018 20:03:09 +0100
Original-Received: by mail-wr0-f200.google.com with SMTP id i6sf1243601wre.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 03 Jan 2018 11:05:13 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1515006313; cv=pass;
        d=google.com; s=arc-20160816;
        b=cAwiDo9bE6h2A0/O4xnDMIyG8PAWcG0du3wVX9Am7iDu3q7pxnRLF9ksfilC1hWnX8
         S6QSzlt1GQ9a99mUe8UUcmhAsL+e0fpkiFGbrX4ZMBFzuR01uJCb9fl505laWqvxvWvj
         aVoZD6ZBYFWaX9H88bYo8OT7J//LtRujHVimIaAOcIihHCBUAaYIxpaGh8ATk7MdMrMB
         zdUgDs+IvRqhIt/g+KRxLYbC3m+VJHnP4UMmIyeFyv1MKXe3ae3BgfJrhaMdBmDJBbeT
         et5MMWkjHRxy943DwlkA1rpY9+BWjjkTr1XPKURX2VwF8Idjk2LFrNp7dODrWMGAQrNJ
         1r0A==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=wY73RR65mHNNqNug9dNJ4NxKNf3vhvKF0ECcqwhmpOU=;
        b=STQHmhniDSfU/4wxMbZtKBrcn+e6OTUz18q5iObjYZ2boYUyqw4fH8YOo8KtDSI/GT
         l2bdWI437oZ0RFgfVqHx7MRjj3KdAC34LTiFcIo0/ypibQ5Bs++HDjVnMqJ+1Y1hqzVa
         77A5QOLr2vBqSKEY9N8pqSUehQFSTa6hA2Z1yn41aKRBz5lQqMQS+H7Tc/5iSCOEUurz
         GOYSVTSKOJLpcNJ3bPA69HPv+7sS0614acQZEORpOxtK7EhjEItJk3aRd/fci2wyHhlo
         djTy9gtajBrVgfYxea5gLq52xWUNIogO0csD8qof5BSbB6HZebi3bB++7t0COosdMAb8
         WC8Q==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=fDMP3bO3;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=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:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=wY73RR65mHNNqNug9dNJ4NxKNf3vhvKF0ECcqwhmpOU=;
        b=ihFCNRcc3tEPqLverzVocKoVByHVmcnnO4whzCIS+rZQEJy8bJxgc8ZyIQibb2ciKQ
         VIYk2iFQzBs0fFc5jNrlGEJq9CrLeqBZtgENWN/61bjtFg5mwa6rXHCbLCHOiKRbTFyq
         5NrfG4vdI5EfVf1WejTamRbyRED20ZfYAXoSE0uRiyl/SRAHnjoAshGvsDUFFziBCvps
         Fo9uBkS0+vggL+/XpBLpOeKcS4ARzDyy8PPvCuLcGskPDgeTYSii4Fh2OuvoRFTHRg1Q
         Sv94f6tztlZ2McvTlp32s/VOCSGg+LvJfqhl/q90mGhCN1gs85xCjqHZ9ppGezJJ4Gu7
         4BQQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state: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=wY73RR65mHNNqNug9dNJ4NxKNf3vhvKF0ECcqwhmpOU=;
        b=Hs8Rq8TPBBaNbmqNXHFlO+XzNGGprNcAS3WX7jkpjvamMCo7fNghOzQ6azGjqB/UK3
         RdiirCBVOi7QeI1YPrO3hd162ljJc/LpQnT1bWFC2Ep+OuN2xUXtJ4Yy3n/zvLG80vNF
         w9wf878SjL+9eBrv4Xpi48E9FNgXlA0lAW8OsDnSS3w192328xzwQj1FO4AhhP9X2/ym
         nNYVP41ZDfLQ5kvSNCJSjGYlazM7I87iQVXfQF8S2Xhpy2ffwrfQQBG8W9F9McaiEJkl
         PjtQI/2DStxmXZSCTvD90wBV1n76tzn+DQ3fIEuJvHd8AOnMhOPfbh5j8uIw6PMO4GbF
         utrg==
X-Gm-Message-State: AKGB3mLDaJMlMcWLrgU5sfru8wcPpCtA1YRRedxsHQxjZocd7/6fen+J
	Fqpegu4yHHIpZn0TWosftnVQxg==
X-Google-Smtp-Source: ACJfBov7M38pnErSuLuS1A5lJIo2W0Qqfwd6SqOv8Q/1Et0GBkLxByhjD4vcqV4E2iOemzbiAhbLLA==
X-Received: by 10.80.174.140 with SMTP id e12mr927132edd.12.1515006312985;
        Wed, 03 Jan 2018 11:05:12 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.80.154.229 with SMTP id p92ls13158611edb.8.gmail; Wed, 03 Jan
 2018 11:05:11 -0800 (PST)
X-Received: by 10.80.163.7 with SMTP id 7mr3945476edn.100.1515006311255;
        Wed, 03 Jan 2018 11:05:11 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1515006311; cv=none;
        d=google.com; s=arc-20160816;
        b=K8vh5YoiPZpiIc5uayaraWioPyoYHQWLq1/4m+quul2kBuCHt0iTAiXYcc8k89OV+C
         DcC/GaKd6futBoDv3oSBa6hIgnbzI/nd2Clr2DUyFe9s1H/L/G/TxLyJzT37ZipG8zQf
         rLjouCn82cAAOva2lrgkbME7bhz1PDpCRmVLvKH09RPcPrucLtRLyoaR1qZIScWvJqmE
         wBJAjV7YC6JC+593/NnVduRx+icks/LWy6noxnCOTp7LyuCcnerD1YNxDhyz/1H+C8ss
         n31KcbU3fAq8xNVAeRW1BbokxxZm6Kh3l7A4o+3PZACSORG0FdMoHW/qGtwnP0TNs9t+
         byHQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=POsWN+NfrogI3dp7SMqbpjds93FpA8ZiKcCuajcCNWw=;
        b=fo1eq9mtgovlS1xb9j7q/1KUwntgKjr43/Nyg/X6La6Ed2c7cXLlfhtpr5qhpHbbik
         PIzo40J2SwSTKEo6cF/uo3irAjo6ZiWyaiTgn8r0Ye6aMyGEXqpzLSu9pV+ExWpuflHH
         bWQCaD4QyCTR88ilb1cRjsYGVroAejSQWRTOVTPNmqJHYbJm+7sKeMEsDQuQq2swKsPL
         VeJN3AO0G1xqtr9fbtIHdhwaVU2vx6aBfZSZPLH3qJwd63X8gUOmCwq+JowL+qh3OgJz
         RaZ9NxBFkCrR7WLacHKVwyx/02fRG7gk+d3dgXhT4Dp2nSAZ2B6veXHwieVg6rYJdnQU
         nMtQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=fDMP3bO3;
       spf=pass (google.com: domain of arthur.j.odwyer@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id w46sor1015516eda.57.2018.01.03.11.05.11
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 03 Jan 2018 11:05:11 -0800 (PST)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.80.148.112 with SMTP id q45mr3893217eda.161.1515006310626;
 Wed, 03 Jan 2018 11:05:10 -0800 (PST)
Original-Received: by 10.80.176.162 with HTTP; Wed, 3 Jan 2018 11:05:10 -0800 (PST)
In-Reply-To: <3356554.N1GgDjyayG@tjmaciei-mobl1>
X-Original-Sender: arthur.j.odwyer@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=fDMP3bO3;       spf=pass
 (google.com: domain of arthur.j.odwyer@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;       dmarc=pass
 (p=NONE sp=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-Spam-Checked-In-Group: 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:36478
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36478>

--f403045c28b8fa3ae30561e3e423
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 3, 2018 at 5:31 AM, Thiago Macieira <thiago@macieira.org> wrote=
:

> On Wednesday, 3 January 2018 10:32:40 -02 Olaf van der Spek wrote:
> > 2018-01-03 12:33 GMT+01:00 Thiago Macieira <thiago@macieira.org>:
> > > On Wednesday, 3 January 2018 08:51:05 -02 olafvdspek@gmail.com wrote:
> > >> Wouldn't the idea be to do the analysis and only consider it a rvalu=
e
> if
> > >> it's NOT accessed later in the statement / function?
> > >
> > > And its address has never been taken, which also means it must never
> have
> > > been passed by reference either. That limits the usefulness too much =
to
> > > make it a feature.
> >
> > Taking the address is fine as long as all references are dead by the
> > time it's considered an rvalue.
>
> And how do you prove that they are?
>

Guys, you're going down an unnecessary rabbit hole here.
The way C++11 solved the problem was just to say that *it doesn't matter*
if there's a live reference or not. Certain syntactic constructs simply
turn into moves (not copies), *regardless* of the number of live references
to the operand.

https://wandbox.org/permlink/DIveFuEiL5JzSkOj
(The output "moved from" indicates that we're observing `Observable o`
*after* it has been moved from, via the reference we stashed.)

Also, please remember that even in simple cases with no aliasing at all,
moving-from an object *does not end its lifetime*. Every object is accessed
at least once after its "last" move-access =E2=80=94 namely, when it is ref=
erenced
by the `this` argument of its own destructor. Moves are *always*
observable. Trying to "hide" moves or pretend that you can do them under
the as-if rule will never work. You *must* confront the human factor
head-on: Which syntactic constructs do human programmers "expect" to
produce moves, and which do they "expect" to produce copies?

HTH,
Arthur

--=20
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 e=
mail 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/CADvuK0LhJMe01RiTW5M52A9WwsG4wzHrgcHiT5jXN59Gyoh=
6AQ%40mail.gmail.com.

--f403045c28b8fa3ae30561e3e423
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Jan 3, 2018 at 5:31 AM, Thiago Macieira <span dir=
=3D"ltr">&lt;<a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiag=
o@macieira.org</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On Wedne=
sday, 3 January 2018 10:32:40 -02 Olaf van der Spek wrote:<br>
&gt; 2018-01-03 12:33 GMT+01:00 Thiago Macieira &lt;<a href=3D"mailto:thiag=
o@macieira.org">thiago@macieira.org</a>&gt;:<br>
&gt; &gt; On Wednesday, 3 January 2018 08:51:05 -02 <a href=3D"mailto:olafv=
dspek@gmail.com">olafvdspek@gmail.com</a> wrote:<br>
&gt; &gt;&gt; Wouldn&#39;t the idea be to do the analysis and only consider=
 it a rvalue if<br>
&gt; &gt;&gt; it&#39;s NOT accessed later in the statement / function?<br>
&gt; &gt;<br>
&gt; &gt; And its address has never been taken, which also means it must ne=
ver have<br>
&gt; &gt; been passed by reference either. That limits the usefulness too m=
uch to<br>
&gt; &gt; make it a feature.<br>
&gt;<br>
&gt; Taking the address is fine as long as all references are dead by the<b=
r>
&gt; time it&#39;s considered an rvalue.<br>
<br>
</span>And how do you prove that they are?<br></blockquote><div><br></div><=
div>Guys, you&#39;re going down an unnecessary rabbit hole here.</div><div>=
The way C++11 solved the problem was just to say that <i><b>it doesn&#39;t =
matter</b></i> if there&#39;s a live reference or not. Certain syntactic co=
nstructs simply turn into moves (not copies), <i><b>regardless</b></i> of t=
he number of live references to the operand.</div><div><br></div><div><a hr=
ef=3D"https://wandbox.org/permlink/DIveFuEiL5JzSkOj">https://wandbox.org/pe=
rmlink/DIveFuEiL5JzSkOj</a><span class=3D"sew91g79wnqs5il"></span><span cla=
ss=3D"sewoupv9y3xeow"></span><br></div><div>(The output &quot;moved from&qu=
ot; indicates that we&#39;re observing `Observable o` <i>after</i> it has b=
een moved from, via the reference we stashed.)</div><div><br></div><div>Als=
o, please remember that even in simple cases with no aliasing at all, movin=
g-from an object <i>does not end its lifetime</i>. Every object is accessed=
 at least once after its &quot;last&quot; move-access =E2=80=94 namely, whe=
n it is referenced by the `this` argument of its own destructor. Moves are =
<i>always</i> observable. Trying to &quot;hide&quot; moves or pretend that =
you can do them under the as-if rule will never work. You <i>must</i> confr=
ont the human factor head-on: Which syntactic constructs do human programme=
rs &quot;expect&quot; to produce moves, and which do they &quot;expect&quot=
; to produce copies?</div><div><br></div><div>HTH,</div><div>Arthur</div></=
div></div></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/CADvuK0LhJMe01RiTW5M52A9WwsG4wzHrgcHi=
T5jXN59Gyoh6AQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0LhJMe01RiT=
W5M52A9WwsG4wzHrgcHiT5jXN59Gyoh6AQ%40mail.gmail.com</a>.<br />

--f403045c28b8fa3ae30561e3e423--

.
