220 41351 <CAB+4KHL-Kgk3rM2pujOs4yhrRw0EU8_7Hx=kiMqF-oRthj14MA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: `bit_cast` and when UB happens.
Date: Sun, 13 Jan 2019 20:18:02 -0600
Lines: 216
Approved: news@gmane.org
Message-ID: <CAB+4KHL-Kgk3rM2pujOs4yhrRw0EU8_7Hx=kiMqF-oRthj14MA@mail.gmail.com>
References: <752cc6a4-24d3-4e86-85a0-3ab0053008d7@isocpp.org>
 <0119543e-6d78-458a-af85-35f122a0b396@isocpp.org> <0c937122-b9e9-4258-a320-19fede2bfe22@isocpp.org>
 <e9d6281d-0256-437a-832f-62d2b885c552@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000474ad5057f61a8b8"
X-Trace: blaine.gmane.org 1547432171 15606 195.159.176.226 (14 Jan 2019 02:16:11 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 14 Jan 2019 02:16:11 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRB2HC57QQKGQE25DMYKI@isocpp.org Mon Jan 14 03:16:07 2019
Return-path: <std-proposals+bncBD5KHQXXWYPRB2HC57QQKGQE25DMYKI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lj1-f199.google.com ([209.85.208.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRB2HC57QQKGQE25DMYKI@isocpp.org>)
	id 1girnL-0003vW-02
	for gclcip-std-proposals@m.gmane.org; Mon, 14 Jan 2019 03:16:07 +0100
Original-Received: by mail-lj1-f199.google.com with SMTP id s64-v6sf5120171lje.19
        for <gclcip-std-proposals@m.gmane.org>; Sun, 13 Jan 2019 18:18:18 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1547432298; cv=pass;
        d=google.com; s=arc-20160816;
        b=Tghu98jENfC0YTgbFfvxjIvmQ6azLus2x5eSod/oMOfKMNRqppPXmvCd1j05NFvY3s
         x4llLKDJvuoiCJYmbpXLFfpBpuOuRbbYw45Ydzks9faHk4V4DXsP0bxB12GE49Ox2gRv
         QS+kPOLb627m1xLdsQqq4DPa7EyqhqekX5hMcfaITXTDRHncTPBC4h1hBBgooRC9NmQV
         909g91/B4rSRAm112mfFf8QqnGdOkb0dS7s/mHuvMZvCiG8Lg9rds4zsCKjZsZ9W6meV
         GWlFiwja52m+VENaRZI48Um7pnjDnSwMlYZh1bGCu5Xw1uRktdJWQaueCbc3C+WpTOie
         +CHA==
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:in-reply-to:references:mime-version:dkim-signature;
        bh=XN8Coi/lI1EKz+C4KkiAhhfylOPk02JvCXLWgeEsceo=;
        b=IvhdJuJgUyNLFczywYYJZZoCZ54w2Kp8wtVBWwaRn2u3N//7BSCHhgeWwJfzh5idp/
         afX/IVa2Z2/YGyY/k5uPss70iFKob8s+/jOrIafa/bC3hffpGlB18uSU1WMEYbHWCZW9
         8fH4UV8e+NX72wxx2/qO8StI2KSekEIrRKlqR03mVI1+W5HXTTLkCozjtOCFYtdXSdzP
         toodDYiHLmbZbus+c206loy8yZ7gMfQ0NCxK4pLh8HLrBqXTK+kTmU+oxiYAAXq5YGcC
         zC+yUzmouWJLm1tnsXQbIExWXKuDsWRy5Z8asT4G77K9Z7x/iOY5qOikpU1d19l0fxoH
         N4pA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=FUUOxCTv;
       spf=pass (google.com: domain of andrewtomazos@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andrewtomazos@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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:references:in-reply-to: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=XN8Coi/lI1EKz+C4KkiAhhfylOPk02JvCXLWgeEsceo=;
        b=tdE5KEMPhEnwGbY6P9kK2BbTd47vktK2xTtzbGoaJbENMR7bPL5u5zXvy5KEmIoIVa
         dbmQuNliGJgEGips5UqxAaQznvbBzdPZJg9kWuQdMWDCk6xP2NGmd3CaCvyb3vV3fGo0
         UZHjjGK6rLqGDTebhFSJHLeZPzTmLa/gS8jIjwVRpORAgWlVIFGq0+GjuEWLazVX3CNA
         7VHImQnmAr6KBuKOnZXpOMRDvZOFgQ/dJLNs8rxe6XV7a+VbamYc7dvVKupQeWCjw1mU
         NyIzJPKDfv+/N3Bum57mVRDgokTXngYQT7O9hn9wK7ruA7KO38YIB7A5howshsDjuMe3
         cCRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to: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=XN8Coi/lI1EKz+C4KkiAhhfylOPk02JvCXLWgeEsceo=;
        b=QaXfPHSvscG5p5ygY9l8+nCrG5sDGeLLQklhKYiGeCZIAwQ0O9q4SxiNPT0Lz0D6p0
         qe0gIFoORC4VPpZGXLIsP42mqTCDdgUrfOvKUBHYk1LpfIth571w3ClzwYd0pCpSNIDt
         OLuRe76W7ctopu/NIyOO0SFf5yQpggBy6y+iKEYc1tc74hcb+1oKzcISxKDa0NY5ubJj
         cp3f8Ze4E9rdSdRLXVAyzA+ZUUFLFCG8vF31yN3si2RCzacp7DIUBnQYc6Nw9BmnedLl
         cAXZl7htuoTAv8sbBiuES4PsxkqM0lvC7SdMcB1vaDIHmswxQA5koFfdaHf3jDKAhr6u
         arPw==
X-Gm-Message-State: AJcUukc8Fhd+HmiIB2Ut0LQ8bWoKwk5ZKXPCq2D17lyuIU4494NpWysO
	Z/ksd7wUV8O+yyQ9UkqLByAFXA==
X-Google-Smtp-Source: ALg8bN5N8iLd9vMstYU29nq1NsRVeUOltyO0u8apxiec0SwVYdcD0A4VW9kYE6ivGh4umQK2pW9NVQ==
X-Received: by 2002:ac2:4207:: with SMTP id y7mr456387lfh.7.1547432297882;
        Sun, 13 Jan 2019 18:18:17 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a2e:5d9d:: with SMTP id v29-v6ls2566291lje.12.gmail; Sun, 13
 Jan 2019 18:18:16 -0800 (PST)
X-Received: by 2002:a2e:8045:: with SMTP id p5-v6mr12726072ljg.87.1547432296082;
        Sun, 13 Jan 2019 18:18:16 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1547432296; cv=none;
        d=google.com; s=arc-20160816;
        b=NtijJzE/VQz7DeelpBUbac4YPrf2uOvfhG5Frc2A1r0w8VAvJST24At1QfLK9xz2/t
         A70qqZ+T702EBKzaofAOjz+1a49AYyRQL94XBQJX8OkmsvTQ3G2LsrceA0ds/RqqTSm+
         AnwdlMrnN8y7Vk6d0C5i/lombfvNmSsIBoDxUJGzzmmVIJ+xgps86c0Vap/+WDVu9/kX
         Z2fLWv7XuM/qJIHf/r/m2bIdYKzcZUgQEBO3elywvGabuCZvdRPOHBk1zIx1e4v23+32
         JS7NoNqUYWM5uGQ0swN0pZx9YjVoVORQ1ShOwvdDGYxfE+wSqReOiDiLPQPc3SIh7Q6b
         DACg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=60fPkOMf2DHBKvzaDDlP/H+7KHOXNyAnd0wegR+0m5o=;
        b=chmmgE3nh1vlG2ZhenkQM12LuwoPyqi33PH+EA6+KFLGbJBR0EoVI5XSU8ffllVXCN
         IJIN8LFA/R2hTKiOqiNwzvBNPAHLjMEWCZsR7ba8W6i7f19nkuXd8t+hsJRpq9kG5RKL
         hO1FmY0xaoYaf02qkiCooxNMPau/WiO2x3ZXNUNSHERf0S/6NS5pFOfVbjcmTQH9nExo
         FqBDgcPh8de4NbWjdNkPa2h6fW+mj+tJMCyom/L+pu5kmF44WfW+CZCY2TlIJHlOAk2u
         5QIy30U1adGoSX7BmjHM0KObjprPzlJQ9CsNSuw5Hxl3KgW5wR0IOErwu5K1+Fu73nVW
         9iiw==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=FUUOxCTv;
       spf=pass (google.com: domain of andrewtomazos@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andrewtomazos@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id y86-v6sor50169531lje.18.2019.01.13.18.18.16
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 13 Jan 2019 18:18:16 -0800 (PST)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:12d0:: with SMTP id 77-v6mr12683190ljs.132.1547432295351;
 Sun, 13 Jan 2019 18:18:15 -0800 (PST)
In-Reply-To: <e9d6281d-0256-437a-832f-62d2b885c552@isocpp.org>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=FUUOxCTv;       spf=pass
 (google.com: domain of andrewtomazos@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=andrewtomazos@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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:41351
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41351>

--000000000000474ad5057f61a8b8
Content-Type: text/plain; charset="UTF-8"

https://stackoverflow.com/q/54175056/1131467

On Sun, Jan 13, 2019 at 7:53 PM T. C. <rs2740@gmail.com> wrote:

>
>
> On Sunday, January 13, 2019 at 7:27:23 PM UTC-5, Nicol Bolas wrote:
>>
>>
>>
>> On Sunday, January 13, 2019 at 6:31:49 PM UTC-5, T. C. wrote:
>>>
>>>
>>>
>>> On Sunday, January 13, 2019 at 3:12:16 PM UTC-5, Nicol Bolas wrote:
>>>>
>>>> P0476R2 specifies when a `bit_cast` yields UB
>>>> <https://wg21.link/P0476R2>:
>>>>
>>>> If there is no value of type `To` corresponding to the value
>>>>> representation produced, the behavior is undefined.
>>>>>
>>>>
>>>> OK, sure. But what does this really mean? Consider the following type:
>>>>
>>>> class specific_bits
>>>> {
>>>> public:
>>>>     specific_bits() = default;
>>>>     explicit specific_bits(int j) : j_(j) {}
>>>>
>>>>     int get_i() const {return i_;}
>>>>
>>>> private:
>>>>     int j_;
>>>>     int i_ = 5;
>>>> };
>>>>
>>>> Now, consider the following operation:
>>>>
>>>> auto sb = bit_cast<specific_bits>(pair<int, int>{10, 20});
>>>>
>>>> Let's assume that the sizes of these types are the same. `pair` is
>>>> TriviallyCopyable, as is `specific_bits`. So, is this well-defined behavior?
>>>>
>>>> Well, `specific_bits` is technically just a pair of integers, so it
>>>> seems like it should be well-defined. However, it is my understanding that
>>>> it is essentially impossible to change the `i_` member of any
>>>> `specific_bits` object to any other value. At least, not from outside of
>>>> the class; anything which would do so would run into UB at some point.
>>>>
>>>
>>> Access control is not watertight enough for that. There are ways you can
>>> get your hands on a pointer to member to specific_bits::i_, at which point
>>> you can modify the field (
>>> http://coliru.stacked-crooked.com/a/62dd7c4bfeb1eb96).
>>>
>>
>> Why isn't `template struct accessor<specific_bits, &specific_bits::i_>;`
>> a compile error? Doesn't it mention a name which is not accessible from
>> that location?
>>
>
> Access checking is not applied to explicit instantiations (with exceptions
> not relevant here). See [temp.spec]/6 in the current WP.
>
> --
> 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/e9d6281d-0256-437a-832f-62d2b885c552%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e9d6281d-0256-437a-832f-62d2b885c552%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAB%2B4KHL-Kgk3rM2pujOs4yhrRw0EU8_7Hx%3DkiMqF-oRthj14MA%40mail.gmail.com.

--000000000000474ad5057f61a8b8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><a href=3D"https://stackoverflow.com/q/54=
175056/1131467">https://stackoverflow.com/q/54175056/1131467</a><br></div><=
/div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Sun, Jan 13, 2019 a=
t 7:53 PM T. C. &lt;<a href=3D"mailto:rs2740@gmail.com">rs2740@gmail.com</a=
>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di=
v dir=3D"ltr"><br><br>On Sunday, January 13, 2019 at 7:27:23 PM UTC-5, Nico=
l Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D=
"ltr"><br><br>On Sunday, January 13, 2019 at 6:31:49 PM UTC-5, T. C. wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><br><br>=
On Sunday, January 13, 2019 at 3:12:16 PM UTC-5, Nicol Bolas wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px=
 solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><a href=3D"https=
://wg21.link/P0476R2" rel=3D"nofollow" target=3D"_blank">P0476R2 specifies =
when a `bit_cast` yields UB</a>:<br><br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
ding-left:1ex">If there is no value of type `To` corresponding to the value=
 representation produced, the behavior is undefined.<br></blockquote><br>OK=
, sure. But what does this really mean? Consider the following type:<br><br=
><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,1=
87);border-style:solid;border-width:1px"><code><div><span style=3D"color:rg=
b(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> specific_bits<br>=
</span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rg=
b(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">public</span><span =
style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)"><br=
>=C2=A0 =C2=A0 specific_bits</span><span style=3D"color:rgb(102,102,0)">()<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">default</span><span style=3D"color:rgb(102,102,0)">;</s=
pan><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> sp=
ecific_bits</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> j</span=
><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"col=
or:rgb(0,0,0)"> j_</span><span style=3D"color:rgb(102,102,0)">(</span><span=
 style=3D"color:rgb(0,0,0)">j</span><span style=3D"color:rgb(102,102,0)">)<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">{}</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 <br>=
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">int</span><span sty=
le=3D"color:rgb(0,0,0)"> get_i</span><span style=3D"color:rgb(102,102,0)">(=
)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0=
,0,136)">const</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,136)">return=
</span><span style=3D"color:rgb(0,0,0)"> i_</span><span style=3D"color:rgb(=
102,102,0)">;}</span><span style=3D"color:rgb(0,0,0)"><br><br></span><span =
style=3D"color:rgb(0,0,136)">private</span><span style=3D"color:rgb(102,102=
,0)">:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> =
j_</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:=
rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">int=
</span><span style=3D"color:rgb(0,0,0)"> i_ </span><span style=3D"color:rgb=
(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(0,102,102)">5</span><span style=3D"color:rgb(102,102,0)">;</s=
pan><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(10=
2,102,0)">};</span></div></code></div><br>Now, consider the following opera=
tion:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px"><code><div><span style=
=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)"> sb </s=
pan><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb=
(0,0,0)"> bit_cast</span><span style=3D"color:rgb(0,136,0)">&lt;specific_bi=
ts&gt;</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"co=
lor:rgb(0,0,0)">pair</span><span style=3D"color:rgb(102,102,0)">&lt;</span>=
<span style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(102,1=
02,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(0,0,136)">int</span><span style=3D"color:rgb(102,102,0)">&gt;{</span>=
<span style=3D"color:rgb(0,102,102)">10</span><span style=3D"color:rgb(102,=
102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"col=
or:rgb(0,102,102)">20</span><span style=3D"color:rgb(102,102,0)">});</span>=
</div></code></div><br>Let&#39;s assume that the sizes of these types are t=
he same. `pair` is TriviallyCopyable, as is `specific_bits`. So, is this we=
ll-defined behavior?<br><br>Well, `specific_bits` is technically just a pai=
r of integers, so it seems like it should be well-defined. However, it is m=
y understanding that it is essentially impossible to change the `i_` member=
 of any `specific_bits` object to any other value. At least, not from outsi=
de of the class; anything which would do so would run into UB at some point=
..<br></div></blockquote><div><br></div><div>Access control is not watertigh=
t enough for that. There are ways you can get your hands on a pointer to me=
mber to specific_bits::i_, at which point you can modify the field (<a href=
=3D"http://coliru.stacked-crooked.com/a/62dd7c4bfeb1eb96" rel=3D"nofollow" =
target=3D"_blank">http://coliru.stacked-crooked.com/a/62dd7c4bfeb1eb96</a>)=
..</div></div></blockquote><div><br></div><div>Why isn&#39;t `template struc=
t accessor&lt;specific_bits, &amp;specific_bits::i_&gt;;` a compile error? =
Doesn&#39;t it mention a name which is not accessible from that location?<b=
r></div></div></blockquote><div><br></div><div>Access checking is not appli=
ed to explicit instantiations (with exceptions not relevant here). See [tem=
p.spec]/6 in the current WP.=C2=A0</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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/e9d6281d-0256-437a-832f-62d2b885c552%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e9d6281d-0256-=
437a-832f-62d2b885c552%40isocpp.org</a>.<br>
</blockquote></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/CAB%2B4KHL-Kgk3rM2pujOs4yhrRw0EU8_7Hx=
%3DkiMqF-oRthj14MA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHL-Kg=
k3rM2pujOs4yhrRw0EU8_7Hx%3DkiMqF-oRthj14MA%40mail.gmail.com</a>.<br />

--000000000000474ad5057f61a8b8--

.
