220 16341 <FE992DB9-9D02-4B2B-A101-22C8E57F090E@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Pointers to members of unknown class
Date: Wed, 18 Feb 2015 01:41:31 +0800
Lines: 130
Approved: news@gmane.org
Message-ID: <FE992DB9-9D02-4B2B-A101-22C8E57F090E@gmail.com>
References: <9b03a820-0ac5-4931-9825-b2fc9ef893f9@isocpp.org> <885c1fbd-8701-4f70-b7ad-89ee9104f42d@isocpp.org> <b9e49990-712d-412e-9789-6aa83f22c0de@isocpp.org> <e33b4000-bcf7-4040-952e-b0a5e81edd60@isocpp.org> <CAD6_Qj8SS1cEtnRgcKXx2-F35151w=VhRnjaGwooJrQCVSyngg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_746C61F7-C9C0-4B75-BA2A-8B2E3D4AC91D"
X-Trace: ger.gmane.org 1424194913 14321 80.91.229.3 (17 Feb 2015 17:41:53 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 17 Feb 2015 17:41:53 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBVP2RWTQKGQEHRCC34I@isocpp.org Tue Feb 17 18:41:45 2015
Return-path: <std-proposals+bncBCW25A7E3QCRBVP2RWTQKGQEHRCC34I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBVP2RWTQKGQEHRCC34I@isocpp.org>)
	id 1YNm9X-0006Jb-2D
	for gclcip-std-proposals@m.gmane.org; Tue, 17 Feb 2015 18:41:43 +0100
Original-Received: by mail-vc0-f197.google.com with SMTP id hy4sf124028771vcb.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 17 Feb 2015 09:41:42 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-type:message-id:mime-version
         :subject:date:references:to:in-reply-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=9MgnwwQH/i0FQje8klBRqw8ZqDzNMO4Kb5xCbGLzjbw=;
        b=CDxrvdRq/ja9jUhHGnu5xqt8ZcACrZZhgboxY8x4sH1LJt2qa6WuSqF9wi//wqREdZ
         kEQNKZ2pd3Jgs/Oir5+c/rVpUbHtKumbm3D7GUbvJxHpwr7JQxiMau6/NXI97HxuE6Fv
         lgB7jiSfEvvXaZxsuyjpHjnAlSEzqCjRfIj4q8ODDIr1+o5zaqxGuqUctG9AJTuCJxbk
         UB1D8rl6UfGA2ABMQZ5XaCug0eC2E3P02INx4GMZtI5rpEjDq6+YMIZa9545rfvikeQ4
         HpZAGqPYOAWuHNfwsrmT3tXrrmIIJo6ZJCK2CIhIa5zoHzk7Qm1B/SoJB8UD5ybvVb7P
         myXA==
X-Gm-Message-State: ALoCoQlBfJrZ+cFsCkg0wyLV410O0N++Q21peRGFV6R88eAyHRBAKy9uHJymKpo349xYE6bLNhBv
X-Received: by 10.236.202.207 with SMTP id d55mr27293967yho.4.1424194902339;
        Tue, 17 Feb 2015 09:41:42 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.8.98 with SMTP id q2ls585262iga.33.gmail; Tue, 17 Feb 2015
 09:41:41 -0800 (PST)
X-Received: by 10.68.139.98 with SMTP id qx2mr51288213pbb.39.1424194901552;
        Tue, 17 Feb 2015 09:41:41 -0800 (PST)
Original-Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com. [209.85.220.47])
        by mx.google.com with ESMTPS id ix2si3819532pac.158.2015.02.17.09.41.41
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 17 Feb 2015 09:41:41 -0800 (PST)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 209.85.220.47 as permitted sender) client-ip=209.85.220.47;
Original-Received: by padbj1 with SMTP id bj1so7864707pad.5
        for <std-proposals@isocpp.org>; Tue, 17 Feb 2015 09:41:41 -0800 (PST)
X-Received: by 10.70.103.162 with SMTP id fx2mr51910021pdb.24.1424194901412;
        Tue, 17 Feb 2015 09:41:41 -0800 (PST)
Original-Received: from [172.20.10.2] ([121.54.44.90])
        by mx.google.com with ESMTPSA id qa1sm10470019pdb.84.2015.02.17.09.41.38
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 17 Feb 2015 09:41:40 -0800 (PST)
In-Reply-To: <CAD6_Qj8SS1cEtnRgcKXx2-F35151w=VhRnjaGwooJrQCVSyngg@mail.gmail.com>
X-Mailer: Apple Mail (2.2070.6)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 209.85.220.47 as permitted sender)
 smtp.mail=potswa@gmail.com;       dkim=pass header.i=@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:16341
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/16341>

--Apple-Mail=_746C61F7-C9C0-4B75-BA2A-8B2E3D4AC91D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9302=E2=80=9317, at 9:48 PM, David Rodr=C3=ADguez Ibeas <di=
beas@ieee.org> wrote:
>=20
> Sorry for looking like the bad guy here, but I am still unsure of the fea=
ture. Little added value and increased dangers as people don't quite unders=
tand pointers to members.
>=20
> To be clear, the Itanium ABI does not have the pointer-to-member sizes de=
scribed in the document to adhere to the requirement of 'reinterpret_cast',=
 but rather as the result of the design of dynamic dispatch in that ABI (wh=
at value is 'this' on entry to the final overrider?).

Virtual functions and virtual bases set requirements for certain PTM types,=
 causing increased size. The reinterpret_cast requirement causes that size =
to apply to all other PTM types, even for classes without virtual anything.

Looking at the proposal again, I find the incomplete classes troubling. Isn=
=E2=80=99t it inconsistent to retroactively change the size of a class=E2=
=80=99 PTMs at the time it gets completed? Shouldn=E2=80=99t pointers to me=
mbers of incomplete classes be incomplete too?

For that matter, MSVC doesn=E2=80=99t go far enough with this optimization.=
 Most classes are less than 256 bytes, and then ordinary PTMs only need one=
 byte.

> I am fine changing the standard to make VS implementation conformant. For=
 that a single change needs to be done: remove the requirement that roundtr=
ip conversions of pointer-to-member are guaranteed (becomes implementation =
defined, still works where it works today, doesn't where it fails today). A=
nother change would then be useful: provide a mechanism to replace the inte=
rmediate point of the roundtrip.  For that you can either extend the gramma=
r to allow for a "pointer to member of unknown type" or provide a different=
 facility.  The simplest would be to have a way of creating a buffer that i=
s "large enough".=20
>=20
> With such a buffer, expressions in the form 'T void::*dst =3D src;' becom=
e 'memcpy(&dst, &src, sizeof src)' (where 'src' is a pointer to member of t=
ype 'T' in some class 'C').  The conversions in the opposite direction are =
the inverse: 'memcpy(&ptr, buffer, sizeof ptr)=E2=80=99.

Sure, any POD type can be constructed from its object representation, and P=
TMs are POD. No special buffer provision is required. Just let the user cal=
l memcpy directly.

Taken to its bare essentials, the proposal is simple indeed!

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_746C61F7-C9C0-4B75-BA2A-8B2E3D4AC91D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9302=
=E2=80=9317, at 9:48 PM, David Rodr=C3=ADguez Ibeas &lt;<a href=3D"mailto:d=
ibeas@ieee.org" class=3D"">dibeas@ieee.org</a>&gt; wrote:</div><br class=3D=
"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D"">Sor=
ry for looking like the bad guy here, but I am still unsure of the feature.=
 Little added value and increased dangers as people don't quite understand =
pointers to members.<br class=3D""><br class=3D"">To be clear, the Itanium =
ABI does not have the pointer-to-member sizes described in the document to =
adhere to the requirement of 'reinterpret_cast', but rather as the result o=
f the design of dynamic dispatch in that ABI (what value is 'this' on entry=
 to the final overrider?).<br class=3D""></div></div></blockquote><div><br =
class=3D""></div><div>Virtual functions and virtual bases set requirements =
for certain PTM types, causing increased size. The <font face=3D"Courier" c=
lass=3D"">reinterpret_cast</font> requirement causes that size to apply to =
all other PTM types, even for classes without virtual anything.</div><div><=
br class=3D""></div><div>Looking at the proposal again, I find the incomple=
te classes troubling. Isn=E2=80=99t it inconsistent to retroactively change=
 the size of a class=E2=80=99 PTMs at the time it gets completed? Shouldn=
=E2=80=99t pointers to members of incomplete classes be incomplete too?</di=
v><div><br class=3D""></div><div>For that matter, MSVC doesn=E2=80=99t go f=
ar enough with this optimization. Most classes are less than 256 bytes, and=
 then ordinary PTMs only need one byte.</div><div><br class=3D""></div><blo=
ckquote type=3D"cite" class=3D""><div class=3D""><div dir=3D"ltr" class=3D"=
">I am fine changing the standard to make VS implementation conformant. For=
 that a single change needs to be done: remove the requirement that roundtr=
ip conversions of pointer-to-member are guaranteed (becomes implementation =
defined, still works where it works today, doesn't where it fails today). A=
nother change would then be useful: provide a mechanism to replace the inte=
rmediate point of the roundtrip.&nbsp; For that you can either extend the g=
rammar to allow for a "pointer to member of unknown type" or provide a diff=
erent facility.&nbsp; The simplest would be to have a way of creating a buf=
fer that is "large enough".&nbsp;<br class=3D""><br class=3D"">With such a =
buffer, expressions in the form 'T void::*dst =3D src;' become 'memcpy(&amp=
;dst, &amp;src, sizeof src)' (where 'src' is a pointer to member of type 'T=
' in some class 'C').&nbsp; The conversions in the opposite direction are t=
he inverse: 'memcpy(&amp;ptr, buffer, sizeof ptr)=E2=80=99.<br class=3D""><=
/div></div></blockquote><div><br class=3D""></div><div>Sure, any POD type c=
an be constructed from its object representation, and PTMs are POD. No spec=
ial buffer provision is required. Just let the user call <font face=3D"Cour=
ier" class=3D"">memcpy</font> directly.</div><div><br class=3D""></div><div=
>Taken to its bare essentials, the proposal is simple indeed!</div></div></=
body></html>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_746C61F7-C9C0-4B75-BA2A-8B2E3D4AC91D--

.
