220 30246 <DM5PR03MB282513F1EFF95A2C111963B189610@DM5PR03MB2825.namprd03.prod.outlook.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "'Neil MacIntosh' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: RE: P0298: A byte type definition: with undefined
 pointer arithmetic?
Date: Wed, 4 Jan 2017 19:21:42 +0000
Lines: 82
Approved: news@gmane.org
Message-ID: <DM5PR03MB282513F1EFF95A2C111963B189610@DM5PR03MB2825.namprd03.prod.outlook.com>
References: <e21a1901-1ed5-5795-6244-dd70c4d08adf@f2.dion.ne.jp>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1483557719 1932 195.159.176.226 (4 Jan 2017 19:21:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 4 Jan 2017 19:21:59 +0000 (UTC)
To: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>, "std-proposals@isocpp.org"
	<std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCT4NWETZQJBBSMWWXBQKGQEPCPXX6I@isocpp.org Wed Jan 04 20:21:47 2017
Return-path: <std-proposals+bncBCT4NWETZQJBBSMWWXBQKGQEPCPXX6I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f199.google.com ([209.85.216.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCT4NWETZQJBBSMWWXBQKGQEPCPXX6I@isocpp.org>)
	id 1cOr84-0007Bh-A6
	for gclcip-std-proposals@m.gmane.org; Wed, 04 Jan 2017 20:21:44 +0100
Original-Received: by mail-qt0-f199.google.com with SMTP id x49sf7714715qtc.7
        for <gclcip-std-proposals@m.gmane.org>; Wed, 04 Jan 2017 11:21:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:thread-topic:thread-index:date:message-id
         :references:in-reply-to:accept-language:content-language
         :spamdiagnosticoutput:spamdiagnosticmetadata
         :content-transfer-encoding:mime-version: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=ZTlcRljpiJouZEbBt+SzWZ9hBB2maQL2BEGCmjk52Ws=;
        b=Ld/9jhBmB9/YMgBq6Po+oxtry36wnFgMtR738/n48d9UJPT/miK8dWuIKf18HBEnaC
         jRvYPh83JKHQmafxQMYZBfS6adTqsI3ugvVvvAn7Z4asFCaL/STSlI+YYLlf1tT0sFsK
         x6xxI1+ykGzJ5YfTp6/D/KIUOZ5GMOtUA18tHU8o2xKxdVpWp/IdjJhaWwskbD3mJp8n
         CS1NdIHyU2uUnXV7feqtGiufV1mUMdaYQD6DlR7x 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:thread-topic:thread-index:date
         :message-id:references:in-reply-to:accept-language:content-language
         :spamdiagnosticoutput:spamdiagnosticmetadata
         :content-transfer-encoding:mime-version: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=ZTlcRljpiJouZEbBt+SzWZ9hBB2maQL2BEGCmjk52Ws=;
        b=iC0negHcRYybekZMFt0BW5o5zllHHC7hLb7pnfyRNKOxgFOkOIv8EaCwBPgb5LC+cJ
         Obwq3QTk0CONJZuPGDTuNW3eE2sfdeexAJhqYJhfYbkslxJjzId2MKeVHDuLQE5KHU+H
         tR496NPLOdyWqD5Y3/J7xp3DnI7d40+bF54fasulNit4S3xw82JTBVmtYYBhHGC9ZwMw
         ZTgB6weaftpY678gNtsGgICw27tKnm4c+xc6 
X-Gm-Message-State: AIkVDXKBbXmasqA9PYiP4AfAy+2GuzaiapfQYGoHLrlGdPPEDtFYcSRURYK0BQ5WXNIeIA==
X-Received: by 10.200.45.243 with SMTP id q48mr17224599qta.7.1483557707297;
        Wed, 04 Jan 2017 11:21:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.140.194 with SMTP id o185ls12559658iod.48.gmail; Wed, 04
 Jan 2017 11:21:44 -0800 (PST)
X-Received: by 10.36.103.198 with SMTP id u189mr53904402itc.9.1483557704306;
        Wed, 04 Jan 2017 11:21:44 -0800 (PST)
Original-Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0706.outbound.protection.outlook.com. [2a01:111:f400:fe40::706])
        by mx.google.com with ESMTPS id 74si28313886iou.249.2017.01.04.11.21.44
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Wed, 04 Jan 2017 11:21:44 -0800 (PST)
Received-SPF: pass (google.com: domain of neil.macintosh@microsoft.com designates 2a01:111:f400:fe40::706 as permitted sender) client-ip=2a01:111:f400:fe40::706;
Original-Received: from DM5PR03MB2825.namprd03.prod.outlook.com (10.175.105.11) by
 DM5PR03MB2828.namprd03.prod.outlook.com (10.175.105.14) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id
 15.1.817.10; Wed, 4 Jan 2017 19:21:42 +0000
Original-Received: from DM5PR03MB2825.namprd03.prod.outlook.com ([10.175.105.11]) by
 DM5PR03MB2825.namprd03.prod.outlook.com ([10.175.105.11]) with mapi id
 15.01.0817.009; Wed, 4 Jan 2017 19:21:42 +0000
Thread-Topic: P0298: A byte type definition: with undefined pointer
 arithmetic?
Thread-Index: AQHSZndgl96bd9O4NEuh6V6iYPQ+OaEosBhg
In-Reply-To: <e21a1901-1ed5-5795-6244-dd70c4d08adf@f2.dion.ne.jp>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [50.46.251.73]
x-ms-office365-filtering-correlation-id: ce0b471a-9ea0-481c-242b-08d434d6ea8c
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR03MB2828;
x-microsoft-exchange-diagnostics: 1;DM5PR03MB2828;7:81rfTwSl5GLj/LW1EoFGps/rXSOHwx5a5MUOTHtEDkqYXAKB+Ixr0Laln47rpDbAOmrWZf7JsyPm/0cRM5t7o+IEbv0QvMnRfvDblxKc5Q3D2SJp5Ue3wWVFnV8Khwh7hGPUal1Drg96T5fN1KRA3pff9T+nVorcrhWORRxEouUs7ZmICrKWAQmquy4xWfFdAIJdeJUjQtoJZOv47+4AooG/2fKXt3TKdDGJ2Nxx2cr44bMbgcmt2T+BibkvqVr6fssEE9GGKMZtc4gQtl2i9Pjb1/nOueRnWV7GvJR8Y/MqK9b5DNZrZJK7vMTPJstPfaSIeEoAcTGBjB4XNfF7mWQEBWR+t41ZMprny8c2cbLfmvGeWR4TWBcVTDQShZ2DTFiggNyXuuaC+1649VuP8gRt0IDnSZi6E6o8nRv/I6NoOOMG4BiVVUTkEKc86KHI6CCGI3BVI5/Cgjx3ONEILEsxl83Q3DVsfq92Iaj3oUg=
x-microsoft-antispam-prvs: <DM5PR03MB2828F1EB8C6464D1CC716A1289610@DM5PR03MB2828.namprd03.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(190756311086443)(189930954265078)(219752817060721);
x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6072148)(6047074);SRVR:DM5PR03MB2828;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2828;
x-forefront-prvs: 0177904E6B
x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(39860400002)(39850400002)(39450400003)(39410400002)(39840400002)(377454003)(199003)(13464003)(189002)(10090500001)(2501003)(66066001)(68736007)(2900100001)(76176999)(101416001)(92566002)(2906002)(189998001)(107886002)(122556002)(5001770100001)(105586002)(106116001)(97736004)(38730400001)(6436002)(54356999)(106356001)(74316002)(7736002)(99286003)(50986999)(305945005)(9686002)(561944003)(2950100002)(25786008)(77096006)(6506006)(33656002)(10290500002)(5660300001)(3660700001)(5005710100001)(6116002)(86612001)(3280700002)(102836003)(3846002)(229853002)(86362001)(81166006)(8936002)(55016002)(7696004)(8990500004)(8676002)(81156014);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR03MB2828;H:DM5PR03MB2825.namprd03.prod.outlook.com;FPR:;SPF:Non
 e;PTR:InfoNoRecords;A:1;MX:1;LANG:en;
received-spf: None (protection.outlook.com: microsoft.com does not designate
 permitted sender hosts)
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
X-OriginatorOrg: microsoft.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2017 19:21:42.7810
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2828
X-Original-Sender: neil.macintosh@microsoft.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@microsoft.com;       spf=pass (google.com: domain of
 neil.macintosh@microsoft.com designates 2a01:111:f400:fe40::706 as permitted
 sender) smtp.mailfrom=Neil.MacIntosh@microsoft.com;       dmarc=pass
 (p=QUARANTINE dis=NONE) header.from=microsoft.com
X-Original-From: Neil MacIntosh <Neil.MacIntosh@microsoft.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:30246
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30246>

Hello Kazutoshi,

There are plenty of examples of programs that perform byte-oriented access =
in the domain of operating systems and communications protocols. Consider r=
eading or writing a wire-protocol, for example. In fact, you seem to go on =
to give a brief sketch of exactly the sort of byte oriented access people w=
ant to perform.

Rather than speculate on core wording myself, and whether or not the patter=
n you described is undefined behavior, I'll just observe that the Core Work=
ing Group reviewed the proposal (twice - once in Oulu, once in Issaquah) an=
d approved it for adoption.

If you have specific questions about array-of-byte access to object represe=
ntations, then these questions would be completely orthogonal to the std::b=
yte proposal. They would exist today with unsigned char, and they would con=
tinue to exist whether or not std::byte is adopted. So modifying the propos=
al to address that issue is unnecessary. This proposal is about creating a =
distinct type for accessing bytes of memory - something that can also be do=
ne today using unsigned char or char. The semantics of such access should n=
ot be changed by the proposal...it's a different issue.

Hope that helps,

Neil.

-----Original Message-----
From: Kazutoshi Satoda [mailto:k_satoda@f2.dion.ne.jp]=20
Sent: Wednesday, January 4, 2017 2:43 AM
To: Neil MacIntosh <Neil.MacIntosh@microsoft.com>; std-proposals@isocpp.org
Subject: P0298: A byte type definition: with undefined pointer arithmetic?

from P0298R2: https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%=
2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0298r2=
..pdf&data=3D02%7C01%7CNeil.MacIntosh%40microsoft.com%7C931c7d44cdb941e437b2=
08d4348e8184%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C63619123404167591=
7&sdata=3DCl8GsBUSn8IgERF6qnnr7G3uCHZBeOmF1cFvwaqajVQ%3D&reserved=3D0
> Motivation and Scope
> Many programs require byte-oriented access to memory. ...

Could you please show examples of such programs?


As I read N4623 (WG21 2016-11 Issaquah Minutes) and saw that the proposal w=
as about to pass through, I want to understand more concretely what is goin=
g.

I suspect that such programs do something like obtaining unsigned char* whi=
ch points to an int object via reinterpret_cast and iterating through it as=
 if the pointer points to an element of unsigned char[sizeof(int)], as I pe=
rsonally have seen many such programs.

However, AFAIK, the current standard doesn't (or fails to) give well-define=
d behavior to such byte-oriented access on objects of arbitrary types.
N4618 5.7 [expr.add] p6 says:
> For addition or subtraction, if the expressions P or Q have type=20
> "pointer to cv T", where T and the array element type are not similar=20
> (4.5), the behavior is undefined.

Then, if "Many programs require ..." is saying what I suspect, I think defi=
ning such byte-oriented accesses should be done before (or within) the prop=
osal. It will also resolve CWG issue 1701:
"Array vs sequence in object representation"
https://na01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fwg21.cmee=
rw.net%2Fcwg%2Fissue1701&data=3D02%7C01%7CNeil.MacIntosh%40microsoft.com%7C=
931c7d44cdb941e437b208d4348e8184%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0=
%7C636191234041685924&sdata=3DRP%2BMlYq7xWlz5BrM13jeaG9fUL6U13iUEpApP5Plgk8=
%3D&reserved=3D0

--
k_satoda

--=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/DM5PR03MB282513F1EFF95A2C111963B189610%40DM5PR03=
MB2825.namprd03.prod.outlook.com.

.
