220 36483 <CADvuK0K1DGi-uv+Fc-33wT=_VR0R6NDThAR-ZFK+=Xcgtrwdrw@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:41:26 -0800
Lines: 154
Approved: news@gmane.org
Message-ID: <CADvuK0K1DGi-uv+Fc-33wT=_VR0R6NDThAR-ZFK+=Xcgtrwdrw@mail.gmail.com>
References: <4ff5fe2d-0945-491f-9888-479b8e866ace@isocpp.org>
 <3356554.N1GgDjyayG@tjmaciei-mobl1> <CADvuK0LhJMe01RiTW5M52A9WwsG4wzHrgcHiT5jXN59Gyoh6AQ@mail.gmail.com>
 <2794319.GCS1XuZPMK@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="94eb2c1b5110bc5f730561e46697"
X-Trace: blaine.gmane.org 1515008379 13607 195.159.176.226 (3 Jan 2018 19:39:39 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 3 Jan 2018 19:39:39 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIORY5U2ICRUBG5BTMGQ@isocpp.org Wed Jan 03 20:39:35 2018
Return-path: <std-proposals+bncBDLZJYWNDQIORY5U2ICRUBG5BTMGQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f71.google.com ([74.125.82.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIORY5U2ICRUBG5BTMGQ@isocpp.org>)
	id 1eWoso-0002mr-A1
	for gclcip-std-proposals@m.gmane.org; Wed, 03 Jan 2018 20:39:26 +0100
Original-Received: by mail-wm0-f71.google.com with SMTP id k126sf983373wmd.5
        for <gclcip-std-proposals@m.gmane.org>; Wed, 03 Jan 2018 11:41:30 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1515008489; cv=pass;
        d=google.com; s=arc-20160816;
        b=tUHZDrXO9PfaieMQWodmplKB2gK0rwKpGbtzYFrRG2yDytYbLCayUnM/bu/5W861yU
         pxui4CyKCiR+Oa2RuBRG8GObs6hU0c5ZPDpwyYEA1T8N4+9gKHQiGul9ObF6rs2cqka4
         pdP55mBPqbNdBncUyjsHyznw6hB3lOFiX2o4wbbGMmBArULGs9Jmp0P2yXKMfbDu2uKf
         CSi+t+08yhdjSupFpKx/GWe2fwpEosrwVUSvXx84MZ/kU70zOKjytatNVwUHoeVJ4Jy4
         IGE11SCIMd3ULVR/JRfnEUF4YqJQo8LCA1mAwRJAl9x6PXvZvpxJEpDpZn4LkubpeHlR
         ysyg==
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=PF2+dkkXIHZ7E+0TphM14uuNzFGmMMphNQQ2/P10zVg=;
        b=ZLmXBe67PIlLQEpV3gUYcIeHJUQpWa2xnDz0eiKwD4K5U2eV2WOeE1O+QEaw0r8NWj
         IDWuJZ7fEP64Qas83bGwY3OGYlvdjZ9sBGvJHcsuLvDecLiRgJGMbrDmSElUK1/YDrSF
         CYsp0skP8EXHnMB4uNxhkjT/UlLK473XsoexF4+Okstcr9w3tY13AZxvLQZZZmmYHnm1
         TNiWa4vAx63jkutWmjwj/IRPQ6nm7fPIxMolw6pSjThkQbptZG2+nNe4SFe9QBhVi30w
         ETuEpPkoPwbPHOgZvKkSjKv95lmy+HFYLqdw4SxjKd9fMzgdHvl9U8bvmVnCN7tn9m4F
         fiCQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=s/yZQKqy;
       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=PF2+dkkXIHZ7E+0TphM14uuNzFGmMMphNQQ2/P10zVg=;
        b=ODnXRfhBvQIZBLKrQxUy9mfLKJVGZhkY59yK3pKJFtcQlXCjj0c0UBqfSU09zQNacn
         paa9IKJi8guQg87R8R9X95XBmwALzktHhBQB3zIWVuQLQBEFx2Dwr2qjNTz3wi5HeFdm
         g4muKvELqBGvsin6ABMmhMaIyVaouAX1dwCnSbGgeWKgfR5URZrqDed3Oj7Uq1QKvdBp
         aS2EIoKPjcsN/YaZ+GSGkVDqCYmJZoJ+tuvX4gjwu5cT4G5dr/OY8UdvOkIdvQzz3Hn8
         ZoCxp9jJpNtYEsspiB1XEOhm7FYH3YA6/DeBx8MAt/yLpDwEH/YjfrNa7MdPxq4nMQQI
         DpWw==
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=PF2+dkkXIHZ7E+0TphM14uuNzFGmMMphNQQ2/P10zVg=;
        b=SNT1JrWGs0ylR971Op43tN2q8hh3G5ehIXX5J3cxXafT15M2ZIEIjQDsO4VUu4HqUR
         uKqYAF8a3C0Jn5Vme/DL4kTUxRD1dOw5iZvITF9SmhJ24F87I72SgCUHp3r0IZqyjkhN
         nB4uacW3BKm0t47E3+LA98rravgoMgTFa6vD/RWfprrDajCKjFItW3atMpnztno8iEFz
         1VMFV/W6/IVw0El3W9PvYQfE31FS5aWhqKyu6g57dcVaFHWDNO1VwCaH/V/mxOZ0zqQc
         PQrCQwqbjlvS4mcM47lwOa0q59631+1pu59XLxpwFYjHqDqFzruTjdcsTuo4tlkCs8mc
         sGwQ==
X-Gm-Message-State: AKGB3mK07rocAbNNiXULqmayHvIFZYJx50OdGEa/S+I2SHUQ0a6k6RVK
	Wm4vdM8U/+rpTVSFAyaanKWT+Q==
X-Google-Smtp-Source: ACJfBovNcAw5fTP3M3CYlMeA3cAorqlSJqM72Jbe4diuR7OCQ6G2G2Tkp5PkinrfMMyZes/9bJZCew==
X-Received: by 10.80.137.157 with SMTP id g29mr957851edg.2.1515008489752;
        Wed, 03 Jan 2018 11:41:29 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.80.212.18 with SMTP id t18ls13185549edh.6.gmail; Wed, 03 Jan
 2018 11:41:28 -0800 (PST)
X-Received: by 10.80.167.99 with SMTP id h90mr4217186edc.110.1515008488198;
        Wed, 03 Jan 2018 11:41:28 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1515008488; cv=none;
        d=google.com; s=arc-20160816;
        b=HWXAvbTV87TH4raszCFAbh8LSTfnkaqrX3MSvvZ2JJWuNqL3g4xgl0OnRUn5GKNdZJ
         wstqjPM3v8mQumg+/kdaSxXTgvy6dcrIT565S1syoV0+zmMnm23OM3Pa7wXWOBVpAMy9
         c+6NcN98hrXB432wGJUFZ4cRr14UdoHN8ufnJEW6ba2UZ0DQVAj+dRsMyFA3l1owOY3x
         ixKBbY4JZZwDmxk+xc9hhaQwE4/Anm0zz7NBB9k2oT+GLaXo+rM7m2DvgSl4lJwljE+D
         TWC8DwvE2r/GQTVk7vgBfEj5ZUwyqWcAwgePheBsGDKdcM1XjmqGU8QLxsoGj2pHIU1G
         a+Vw==
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=LcMarBbOFAjEu5j1nV/TewyhvgOUrhIMtQgbdYjBZUc=;
        b=uSkt2oBOdfw1+T/g8qjZV5mNBO6RUFYdIDpAwhuni5Ol7vATdXlULTHHB2Y62Y1hZp
         Tb25UqZnd2xnw5gsmLmONxECguWCljvjGhZQ6wEWfP2qcSpOZP9IiTIMIc5EHqpFWwuw
         gniUhoOxl/Sz/ZdsyDkQO9ic/UQB8y5+QESwOxsqO9JqVLrZ3F6FuN+g1Vl+6qJLo6is
         ku/+4QVQfwvPi8Z5YNY6lrVhfmOG4PbMNTMuRyXyrurI9/bA1nUiFG4wRn9BEQ67Vg9o
         1X4nq0fhCvavBI/XnwuujOpykzIjdiv5EpMDq5svSkF+DcxwiBtKcu5amhNJBVYuvl0N
         Um6Q==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=s/yZQKqy;
       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 v15sor1046646edl.35.2018.01.03.11.41.28
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 03 Jan 2018 11:41:28 -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.194.74 with SMTP id t10mr4139867edf.116.1515008487610;
 Wed, 03 Jan 2018 11:41:27 -0800 (PST)
Original-Received: by 10.80.176.162 with HTTP; Wed, 3 Jan 2018 11:41:26 -0800 (PST)
In-Reply-To: <2794319.GCS1XuZPMK@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=s/yZQKqy;       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:36483
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36483>

--94eb2c1b5110bc5f730561e46697
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 3, 2018 at 11:33 AM, Thiago Macieira <thiago@macieira.org>
wrote:

> On Wednesday, 3 January 2018 17:05:10 -02 Arthur O'Dwyer wrote:
> > 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 matte=
r*
> > 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.
>
> Indeed, but that was done because in those cases, any live references wer=
e
> about to become dangling anyway, so any well-defined program would never
> use
> them after this point.


You snipped out the example of a well-defined program that used them after
that point. Here it is again.
https://wandbox.org/permlink/DIveFuEiL5JzSkOj
Perfectly well-defined. No undefined behavior here.


It was safe to move from this particular object.
>

I'd tend to agree with you there. However, please continue to remember that
"safe" is a human concept, not a computerese concept. It's "safe" to move
from `o` in this case because that's what the human programmer "expected."
If the human programmer hadn't expected `o` to appear "moved from" in the
second output =E2=80=94 such that that faulty expectation had caused the co=
mputer
to launch missiles or crash the plane or whatever =E2=80=94 then it wouldn'=
t have
been "safe" after all.


> 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
> referenced
> > by the `this` argument of its own destructor. Moves are *always*
> > observable. Trying to "hide" moves or pretend that you can do them unde=
r
> > 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?
>
> All true.
>

=E2=80=93Arthur

--=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/CADvuK0K1DGi-uv%2BFc-33wT%3D_VR0R6NDThAR-ZFK%2B%=
3DXcgtrwdrw%40mail.gmail.com.

--94eb2c1b5110bc5f730561e46697
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Jan 3, 2018 at 11:33 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 17:05:10 -02 Arthur O&#39;Dwyer wrote:<br>
&gt; Guys, you&#39;re going down an unnecessary rabbit hole here.<br>
</span>&gt; The way C++11 solved the problem was just to say that *it doesn=
&#39;t matter*<br>
<span class=3D"">&gt; if there&#39;s a live reference or not. Certain synta=
ctic constructs simply<br>
</span>&gt; turn into moves (not copies), *regardless* of the number of liv=
e references<br>
&gt; to the operand.<br>
<br>
Indeed, but that was done because in those cases, any live references were<=
br>
about to become dangling anyway, so any well-defined program would never us=
e<br>
them after this point.</blockquote><div><br></div><div>You snipped out the =
example of a well-defined program that used them after that point. Here it =
is again.</div><div><a href=3D"https://wandbox.org/permlink/DIveFuEiL5JzSkO=
j" target=3D"_blank" style=3D"font-size:13px">https://wandbox.org/permlink/=
<wbr>DIveFuEiL5JzSkOj<span class=3D"sewjv75brkwdpx4"></span><span class=3D"=
sewldzyip7aq7z5"></span></a><br></div><div><div>Perfectly well-defined. No =
undefined behavior here.</div><div><br></div><div><br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;=
border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex=
">It was safe to move from this particular object.<span class=3D""><br></sp=
an></blockquote></div><div><span class=3D"sewjv75brkwdpx4"></span><span cla=
ss=3D"sewldzyip7aq7z5"></span><br></div><div>I&#39;d tend to agree with you=
 there. However, please continue to remember that &quot;safe&quot; is a hum=
an concept, not a computerese concept. It&#39;s &quot;safe&quot; to move fr=
om `o` in this case because that&#39;s what the human programmer &quot;expe=
cted.&quot; If the human programmer hadn&#39;t expected `o` to appear &quot=
;moved from&quot; in the second output =E2=80=94 such that that faulty expe=
ctation had caused the computer to launch missiles or crash the plane or wh=
atever =E2=80=94 then it wouldn&#39;t have been &quot;safe&quot; after all.=
</div><div><br></div><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span cl=
ass=3D"">
&gt; Also, please remember that even in simple cases with no aliasing at al=
l,<br>
</span>&gt; moving-from an object *does not end its lifetime*. Every object=
 is accessed<br>
<span class=3D"">&gt; at least once after its &quot;last&quot; move-access =
=E2=80=94 namely, when it is referenced<br>
</span>&gt; by the `this` argument of its own destructor. Moves are *always=
*<br>
<span class=3D"">&gt; observable. Trying to &quot;hide&quot; moves or prete=
nd that you can do them under<br>
</span>&gt; the as-if rule will never work. You *must* confront the human f=
actor<br>
<span class=3D"">&gt; head-on: Which syntactic constructs do human programm=
ers &quot;expect&quot; to<br>
&gt; produce moves, and which do they &quot;expect&quot; to produce copies?=
<br>
<br>
</span>All true.<br></blockquote><div><br></div><div>=E2=80=93Arthur=C2=A0<=
/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/CADvuK0K1DGi-uv%2BFc-33wT%3D_VR0R6NDT=
hAR-ZFK%2B%3DXcgtrwdrw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0K1=
DGi-uv%2BFc-33wT%3D_VR0R6NDThAR-ZFK%2B%3DXcgtrwdrw%40mail.gmail.com</a>.<br=
 />

--94eb2c1b5110bc5f730561e46697--

.
