220 37366 <dcd5b3da-0018-4eca-b7a6-b94e950de2de@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Myriachan <myriachan@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: `offsetof` in a macro-less, modular world
Date: Fri, 16 Mar 2018 11:56:29 -0700 (PDT)
Lines: 161
Approved: news@gmane.org
Message-ID: <dcd5b3da-0018-4eca-b7a6-b94e950de2de@isocpp.org>
References: <c5f5ccc4-3267-442d-8cb2-de1ae103a38e@isocpp.org>
 <2034613.rN3AoRdNao@tjmaciei-mobl1> <d4126e87-47a3-2693-e731-5a0f7f1d6732@gmail.com>
 <2319008.6H3YVR8kxN@tjmaciei-mobl1>
 <CAHSYqdbvMA-gv+eP1iu53J6pnLTmr9KjR4_0XJBnEsy5qth=+A@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2119_1204606126.1521226589362"
X-Trace: blaine.gmane.org 1521226475 1524 195.159.176.226 (16 Mar 2018 18:54:35 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Mar 2018 18:54:35 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKLT4PURQHRBXVGWDKQKGQEP2AEO3Q@isocpp.org Fri Mar 16 19:54:31 2018
Return-path: <std-proposals+bncBDKLT4PURQHRBXVGWDKQKGQEP2AEO3Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f199.google.com ([209.85.217.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDKLT4PURQHRBXVGWDKQKGQEP2AEO3Q@isocpp.org>)
	id 1ewuUi-0000Ab-K8
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Mar 2018 19:54:24 +0100
Original-Received: by mail-ua0-f199.google.com with SMTP id w9sf6791911uaa.17
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Mar 2018 11:56:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=7/nL6ZN8gohFZEctBmwAdZVrn+ictTxZu8HtsUJbehA=;
        b=kHQ8/qY3CcfrkzYSbblEaxoDzMar9IQ0W57Dk34Um4g/Ycmzh8tuFCD2wdsi6oCocl
         Kv3+fDa2BiyKY59P5YYQUK2dNi748u8tylkUc3h/CBa+ARLgdNnTLEYABikrdB5hON3l
         Gc8rLwkJ0MAdSKHofPFn+7a9Siq4b678rLAwne8fmVOA4dyN0q68co8JF0c5mq7WiewZ
         veYStGlomlVk8NEGs5x7DgWSAPbMYG9i7pV9t1l65Amu+A12zFLa3ToXQcHdead/Ts26
         spVm43CCtsj+cGc2ei8Ox4DnvKU1cTTy9aa5qD6Ph8pBCrdiFDsC//uMOIGAPS1rF3tC
         DEyA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=7/nL6ZN8gohFZEctBmwAdZVrn+ictTxZu8HtsUJbehA=;
        b=dD7Jzim1lzCI2U5WXdP44ay/rzogQZ7Ufec7mFIbvpJxxijR5uR26QEO2xJ8QtuK7/
         z6UsF+F7b+H4OvNmOrxArTQ/Xi1o8N69mgpS9Yg9lzf4EhF2aRuWX6gYKNESEgZnfYMo
         +Qld6jBz8Ny6tSBnng070It3FJKIQGFYvW1aw7F9N7lcqOQOwV0aynge/s1GUcVfufa3
         DXXwU3aHwLwnLsVlhnsh/oJVNZxE4Slhjq7dLW3ePmrRcdGk35nNi7y/xhkHU1zlprGC
         uppx0Czd4OMGfE5SG8/z4CEG1zkmGwf0QZFAXwlP9JGP+rzE2bmPPpz5tdtWG7SJ2iYI
         u89Q==
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:in-reply-to:references
         :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=7/nL6ZN8gohFZEctBmwAdZVrn+ictTxZu8HtsUJbehA=;
        b=N0VCQebmoMK3ki4L8gBiCZDhmHHx2xi1lziBs6fQelGMgHXj+goXsZJc/YuDIGRiYL
         9xoHVoPliIwa255w8WCmfnvvlIA6aIj5goeeVphjSwNEHF1odxLdABht/Bqk3Hzds4C9
         ENYnubIgd4XKSMTEM0Uo+2ZKc6BXu2r0lvu18S0e+8auXNuS5pm2SWBijzcE8b4asZAd
         SbaE2LDMli0y/EDX5VMomjC33hVP/ZBJm7pshNlc4xbz7TzNZhaByV7xm9VVHcclD2Q8
         TytNUO8WWeFsBTAhMz+Ay98cn+3ImL9BL/rI/iXHNRRoEiJ7pIDvoVDh3jMZj1PgVAJ1
         txMw==
X-Gm-Message-State: AElRT7GpD1i5mnT+xCVx0gEEqQSK5phmlkdXedVfKyOoiTZ4hyuHHppR
	zVkB8AcXL1uyOi7W0h7wG1BDnw==
X-Google-Smtp-Source: AG47ELvUBGg3zUddbCGpE6x0rVVgwF9pSMFLywUFDi+XkBLuUFCR2I/AclSNiMgkKVcPdTCdaKR6Hw==
X-Received: by 10.159.57.214 with SMTP id p22mr1205613uag.20.1521226591500;
        Fri, 16 Mar 2018 11:56:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.146.138 with SMTP id u132ls4300275vkd.13.gmail; Fri, 16 Mar
 2018 11:56:30 -0700 (PDT)
X-Received: by 10.31.193.140 with SMTP id r134mr330143vkf.6.1521226590055;
        Fri, 16 Mar 2018 11:56:30 -0700 (PDT)
In-Reply-To: <CAHSYqdbvMA-gv+eP1iu53J6pnLTmr9KjR4_0XJBnEsy5qth=+A@mail.gmail.com>
X-Original-Sender: myriachan@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:37366
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37366>

------=_Part_2119_1204606126.1521226589362
Content-Type: multipart/alternative; 
	boundary="----=_Part_2120_2045095458.1521226589362"

------=_Part_2120_2045095458.1521226589362
Content-Type: text/plain; charset="UTF-8"

On Friday, March 16, 2018 at 8:13:44 AM UTC-7, Hyman Rosen wrote:
>
>
>     struct A { int x[10]; };
>     struct B { A a; };
>     int B::*number_5 = &B::a.x[5];
>

Careful here: this is a breaking change.  Consider this currently-legal 
code:

struct W { int x[10]; };
struct X { W w; };
struct Y { W w; };
struct Z : X, Y
{
    void f();
};

void Z::f()
{
    int *p = &Y::w.x[5];
    *p = 4;
}

You'd need to use parentheses and define operators . and [] on member 
operators in order to solve this:

(&B::a).x[5]

I really like Thiago's proposal regarding data member pointers, but it has 
a major problem: it's an ABI break.  Some proposed constructions would 
allow data member pointers with a negative offset (pointing to the 
containing class's members), and both the Microsoft and Itanium ABIs encode 
null member pointers as -1.

Melissa

-- 
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/dcd5b3da-0018-4eca-b7a6-b94e950de2de%40isocpp.org.

------=_Part_2120_2045095458.1521226589362
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, March 16, 2018 at 8:13:44 AM UTC-7, Hyman Rosen=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><=
div class=3D"gmail_quote"><br><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 struct A { int x[10]; };<br>=C2=A0 =C2=A0 struct B { A a; };<br>=
=C2=A0 =C2=A0 int B::*number_5 =3D &amp;B::a.x[5];</font></div></div></div>=
</div></blockquote><div><br>Careful here: this is a breaking change.=C2=A0 =
Consider this currently-legal code:<br><br><div style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> W </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">];</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> X </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> W=
 w</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> Y </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> W w</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> Z </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> Y<br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> Z</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">f</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">p </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">Y</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">w</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">x</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">];</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">p </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">4</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></=
code></div><br>You&#39;d need to use parentheses and define operators . and=
 [] on member operators in order to solve this:<br><br>(&amp;B::a).x[5]<br>=
<br>I really like Thiago&#39;s proposal regarding data member pointers, but=
 it has a major problem: it&#39;s an ABI break.=C2=A0 Some proposed constru=
ctions would allow data member pointers with a negative offset (pointing to=
 the containing class&#39;s members), and both the Microsoft and Itanium AB=
Is encode null member pointers as -1.<br><br>Melissa<br></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/dcd5b3da-0018-4eca-b7a6-b94e950de2de%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/dcd5b3da-0018-4eca-b7a6-b94e950de2de=
%40isocpp.org</a>.<br />

------=_Part_2120_2045095458.1521226589362--

------=_Part_2119_1204606126.1521226589362--

.
