220 35788 <383622f1-4c62-4af6-b684-c3d0fdcd3b9c@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: Does guaranteed elision breaks bit_cast?
Date: Wed, 6 Dec 2017 11:43:31 -0800 (PST)
Lines: 108
Approved: news@gmane.org
Message-ID: <383622f1-4c62-4af6-b684-c3d0fdcd3b9c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_577_139033694.1512589411209"
X-Trace: blaine.gmane.org 1512589410 22713 195.159.176.226 (6 Dec 2017 19:43:30 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 6 Dec 2017 19:43:30 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBY4QUHIQKGQE5FMJ3GA@isocpp.org Wed Dec 06 20:43:26 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBY4QUHIQKGQE5FMJ3GA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f197.google.com ([209.85.217.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBY4QUHIQKGQE5FMJ3GA@isocpp.org>)
	id 1eMfbJ-0005qc-IM
	for gclcip-std-proposals@m.gmane.org; Wed, 06 Dec 2017 20:43:25 +0100
Original-Received: by mail-ua0-f197.google.com with SMTP id n23sf3214414uab.11
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Dec 2017 11:43:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=iKUBlIaH1NworhgGFaAiMiwabDCnqzncDS89YgYdrko=;
        b=LfuCI7Tnb5wJBsKKid3RQZIqHG9yEELNmVW+yAsRhy/ZFdjTGlhZzDZf4HGro/AzJR
         RMXqwqCUUFJCo5+OMBeNHgm/Qm3zwhRtwFolseu5AlT2/hnYm35+mDwVrWmDoiRBMfEm
         9iSYjcCqVsdErd2tfM6JYUfvU4Kkr/uP3r+dwsuI9zjcqszl1YTHSI8NMilBumpCP91E
         kdU4dJtjlDc6HZMivBRx6mWARkJgiET0TMroCCycV/XrxMY3LdXvRgbsrwCydfEYxQ6/
         5x0nJQ243o8MHrVNRRW/Qo6EwMY99t7P05grv6ZrZXc47j88MtHE0q/X3RQ/5sKPFBsB
         UO9g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=iKUBlIaH1NworhgGFaAiMiwabDCnqzncDS89YgYdrko=;
        b=lYurmevr/CJPc3M1fF6R/5fUzSbD9nJB1TUIek632KeFXkwJPJdY8u/LEdBPk0pCaM
         9CaELh9ZtPAuQqf2sx7yl18uXIlJPc8lYtyFhLZsWko9xpN1VoJKzj1bHbrIilqdUKB+
         ZSeElByOD/VQzgGq142/niFu4Mz9jh8oy+5VAn0d/yLOBFujd4+S7qEpJkNfT2wR7eKF
         /W0FFzSnp/gD4puUEmDnISgNuuGTSaztqjtbx1/PfreCMLo8drARIo4mmSnVLek+cGkb
         tUB2rtH+xm4TgzMEUwfFjUUx1s70mV23pFgfdDthr73prsRAEcc+ir/wZHxN7tXgrUGm
         jDMA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id: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=iKUBlIaH1NworhgGFaAiMiwabDCnqzncDS89YgYdrko=;
        b=jzZIO7LTed7ntArEPtnP0ZMjZL/amDdhh1rObtoQs3w0BfN6XNvH0O41VQj+4pgaU2
         jGuA3WRIXSsCFsYHXRjJY9z1RD83qud1IYQ903N6ZymASgf7yKPRTWcVSxGQw0EcKAXG
         TSODp7nBxJm8WfnypaBxZVz4GW3Y9Qgn6i/l0zR2YRJSHeL8s4kWfZCTQDRPLtHuSHO7
         BQGmF4WkSAcvBUCQD4rNqWtaF/9nEOOGGGggmWYz4Mwxv7/eir9n7AaMzsWiMg8Cx3eu
         0s3XMJMOmQPlnAXeUjEUTBhZAqTuomDjieWhYXxqJhq0GU4Ivy6PcnWPj2PIluwfqwNj
         IfhQ==
X-Gm-Message-State: AKGB3mJv+6WZak7To8Iij1imuWtnZCQs4OCxsszpNKJiitGxgQLvqomk
	ss1jNuKMgOdBiC9xb7R7bEOF7A==
X-Google-Smtp-Source: AGs4zMa/XUM9RqiWwdVLxA7Ep/T7xChxx7dm0lEQuNhQRkd78zDpjpVCyOXHplO4K7XnqFUy1ZyqsQ==
X-Received: by 10.176.9.233 with SMTP id e41mr3613343uah.39.1512589412891;
        Wed, 06 Dec 2017 11:43:32 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.176.21.233 with SMTP id j38ls3722716uae.3.gmail; Wed, 06 Dec
 2017 11:43:31 -0800 (PST)
X-Received: by 10.31.41.81 with SMTP id p78mr700628vkp.2.1512589411611;
        Wed, 06 Dec 2017 11:43:31 -0800 (PST)
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:35788
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35788>

------=_Part_577_139033694.1512589411209
Content-Type: multipart/alternative; 
	boundary="----=_Part_578_1276454921.1512589411209"

------=_Part_578_1276454921.1512589411209
Content-Type: text/plain; charset="UTF-8"

The new `bit_cast` feature voted into C++20 allows you to do this:

int i = ...;
float j = bit_cast<float>(i);

Assuming the two types have the same size.

The concern is what happens with this:

int i = ...;
float *f = new(&i) auto(bit_cast<float>(i));

Well, the rules of guaranteed elision require that the prvalue returned by 
`bit_cast` directly initializes the object. And that object's storage is 
the same as the parameter passed to `bit_cast`.

So... how exactly does that work? Is this just something that is just for 
implementers to worry about? Or should there be standard wording to 
explicitly forbid this?

-- 
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/383622f1-4c62-4af6-b684-c3d0fdcd3b9c%40isocpp.org.

------=_Part_578_1276454921.1512589411209
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>The new `bit_cast` feature voted into C++20 allows yo=
u to do this:</div><div><br></div><div class=3D"prettyprint" style=3D"borde=
r: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: r=
gb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span class=3D"styled-by-prettify" style=3D"color: #008;">int</span><spa=
n class=3D"styled-by-prettify" style=3D"color: #000;"> i </span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">=3D</span><span class=3D"sty=
led-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-pr=
ettify" style=3D"color: #660;">...;</span><span class=3D"styled-by-prettify=
" style=3D"color: #000;"><br></span><span class=3D"styled-by-prettify" styl=
e=3D"color: #008;">float</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"> j </span><span class=3D"styled-by-prettify" style=3D"color: =
#660;">=3D</span><span class=3D"styled-by-prettify" style=3D"color: #000;">=
 bit_cast</span><span class=3D"styled-by-prettify" style=3D"color: #080;">&=
lt;float&gt;</span><span class=3D"styled-by-prettify" style=3D"color: #660;=
">(</span><span class=3D"styled-by-prettify" style=3D"color: #000;">i</span=
><span class=3D"styled-by-prettify" style=3D"color: #660;">);</span></div><=
/code></div><div><br></div><div>Assuming the two types have the same size.<=
/div><div><br></div><div>The concern is what happens with this:</div><div><=
br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187=
, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code=
 class=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-=
by-prettify" style=3D"color: #008;">int</span><span class=3D"styled-by-pret=
tify" style=3D"color: #000;"> i </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: #660;">=3D</span><span class=3D"styled-by-prettify" style=3D=
"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #=
660;">...;</span><span class=3D"styled-by-prettify" style=3D"color: #000;">=
<br></span><span class=3D"styled-by-prettify" style=3D"color: #008;">float<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><sp=
an class=3D"styled-by-prettify" style=3D"color: #660;">*</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;">f </span><span class=3D"styl=
ed-by-prettify" style=3D"color: #660;">=3D</span><span class=3D"styled-by-p=
rettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" =
style=3D"color: #008;">new</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">(&amp;</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;">i</span><span class=3D"styled-by-prettify" style=3D"color: #6=
60;">)</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: #008;">auto</span><s=
pan class=3D"styled-by-prettify" style=3D"color: #660;">(</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;">bit_cast</span><span class=
=3D"styled-by-prettify" style=3D"color: #080;">&lt;float&gt;</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: #660;">(</span><span class=3D"st=
yled-by-prettify" style=3D"color: #000;">i</span><span class=3D"styled-by-p=
rettify" style=3D"color: #660;">));</span></div></code></div><div><br></div=
><div>Well, the rules of guaranteed elision require that the prvalue return=
ed by `bit_cast` directly initializes the object. And that object&#39;s sto=
rage is the same as the parameter passed to `bit_cast`.</div><div><br></div=
><div>So... how exactly does that work? Is this just something that is just=
 for implementers to worry about? Or should there be standard wording to ex=
plicitly forbid this?</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/383622f1-4c62-4af6-b684-c3d0fdcd3b9c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/383622f1-4c62-4af6-b684-c3d0fdcd3b9c=
%40isocpp.org</a>.<br />

------=_Part_578_1276454921.1512589411209--

------=_Part_577_139033694.1512589411209--

.
