220 26590 <DA1D891D-5D63-44A8-BA31-A8D9BCC9E684@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Jonathan Coe <jonathanbcoe@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allow zero size arrays and let them occupy zero bytes.
Date: Wed, 6 Jul 2016 14:25:07 +0100
Lines: 133
Approved: news@gmane.org
Message-ID: <DA1D891D-5D63-44A8-BA31-A8D9BCC9E684@gmail.com>
References: <51e6aec9-a745-4fd9-94f7-bdd78b5798ca@isocpp.org> <CALnjya-8Kn7VR3J0yxfPoR+zpDGDNxXSUwh4ZpD-t1KdbN9Prw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (1.0)
Content-Type: multipart/alternative;
	boundary=Apple-Mail-9097D46E-DDCE-45CF-ACDC-74A4191AF82A
Content-Transfer-Encoding: 7bit
X-Trace: ger.gmane.org 1467811520 11127 80.91.229.3 (6 Jul 2016 13:25:20 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 6 Jul 2016 13:25:20 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC2JVFPBRAHBBNUN6S5QKGQELLEUNPQ@isocpp.org Wed Jul 06 15:25:14 2016
Return-path: <std-proposals+bncBC2JVFPBRAHBBNUN6S5QKGQELLEUNPQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC2JVFPBRAHBBNUN6S5QKGQELLEUNPQ@isocpp.org>)
	id 1bKmpD-0002Lg-QG
	for gclcip-std-proposals@m.gmane.org; Wed, 06 Jul 2016 15:25:11 +0200
Original-Received: by mail-lf0-f71.google.com with SMTP id g18sf158353018lfg.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Jul 2016 06:25:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:content-transfer-encoding:mime-version:subject:message-id:date
         :references:in-reply-to: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=OrF+GXyDV/oE+jnkk9e+FTR6Ang201sPIwqqJP6sC/0=;
        b=F3YTHn0P0sjK0m2oglWaBQDxp472l0enBXH5xb0Lh3J/F10AeN7b3aJMMXiYUKLDTk
         A7LWTZGWU9l41SK0X4EnsxlI1nIzGhIYmz8u6rpODhvDpgUvnDAfwOA06FJWchnoCp8J
         7SXLk09ifJpVpMv4I0ZOfVxcQUzMNAnIcAZrW3esX8+Z8n9vc/qjmH2IQd2LOJug6anH
         DuDa78S30p+1te8vRZTT5zxTVHehNEVXM5mPYT+K/EWRmRF2wdIlsNegIyPcUTG5NCyt
         3d18I3ZIjAqO2hb1z4v1/swQ/DvYTArSYYK8hSBWAd7CkJb/Z/k5gw+gOczpJ6v/ZHkE
         +Tfw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-transfer-encoding:mime-version
         :subject:message-id:date:references:in-reply-to: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=OrF+GXyDV/oE+jnkk9e+FTR6Ang201sPIwqqJP6sC/0=;
        b=XdagovAzzR0josMk8j83JUDATNvz+TZ4VwxrxubdME/7A5F0SaktpxUB//t1VF/BxL
         BlnlsT5OxyNb/lovU8PHV4knSmyrOnYoh+NDB+ioTUds4e0sv6OPKtQ6800vaRSrIGQp
         86nlP+/19xYbI59nSyA8Ycey0dpDtXrlqTp9I3ZUzYO929h4yKoiq5sBavh57vWgMUcp
         utBLeGJdgEI2J7qBBSt/SIQrr/5qUq4hdOL/hoFr0OS4msrxyvmiLh5UajYb+xGUPgrd
         czKGdpxFzoxTx0ZVU8NvUQmd2xzx4fKQrjtpJLdotGZkhLafxngAcXjEE115XZfJad+x
         BCS 
X-Gm-Message-State: ALyK8tI5TpHfbUs7eo2z6YxIqOxeEl3MV09RgmfD7PfnttBaMvfvvvVO1GRcMvZbat/3Gw==
X-Received: by 10.194.16.233 with SMTP id j9mr3341059wjd.0.1467811511155;
        Wed, 06 Jul 2016 06:25:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.29.20 with SMTP id d20ls789413wmd.12.canary; Wed, 06 Jul
 2016 06:25:10 -0700 (PDT)
X-Received: by 10.194.66.101 with SMTP id e5mr4023346wjt.143.1467811510035;
        Wed, 06 Jul 2016 06:25:10 -0700 (PDT)
Original-Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com. [2a00:1450:400c:c09::22d])
        by mx.google.com with ESMTPS id j142si368066wmg.142.2016.07.06.06.25.10
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 06 Jul 2016 06:25:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of jonathanbcoe@gmail.com designates 2a00:1450:400c:c09::22d as permitted sender) client-ip=2a00:1450:400c:c09::22d;
Original-Received: by mail-wm0-x22d.google.com with SMTP id z126so111670797wme.0
        for <std-proposals@isocpp.org>; Wed, 06 Jul 2016 06:25:10 -0700 (PDT)
X-Received: by 10.194.11.5 with SMTP id m5mr20706563wjb.119.1467811509460;
        Wed, 06 Jul 2016 06:25:09 -0700 (PDT)
Original-Received: from [10.120.227.94] ([213.205.195.94])
        by smtp.gmail.com with ESMTPSA id vs4sm1140553wjb.24.2016.07.06.06.25.08
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Wed, 06 Jul 2016 06:25:08 -0700 (PDT)
In-Reply-To: <CALnjya-8Kn7VR3J0yxfPoR+zpDGDNxXSUwh4ZpD-t1KdbN9Prw@mail.gmail.com>
X-Mailer: iPhone Mail (13F69)
X-Original-Sender: jonathanbcoe@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 jonathanbcoe@gmail.com designates 2a00:1450:400c:c09::22d as permitted
 sender) smtp.mailfrom=jonathanbcoe@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-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:26590
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26590>


--Apple-Mail-9097D46E-DDCE-45CF-ACDC-74A4191AF82A
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



> On 6 Jul 2016, at 13:06, Mathias Gaunard <mathias@gaunard.com> wrote:
>=20
>> On 4 July 2016 at 16:15, Bengt Gustafsson <bengt.gustafsson@beamways.com=
> wrote:
>> I have been following the recent thread about empty base optimization, o=
r rather, the lack of empty member optimization possibility. And today I ag=
ain fell in the 0 sized array trap in metaprogramming, noticing that it cre=
ates quite a few problems requiring extra coding.
>>=20
>> This idea struck me to solve both of these issues at once by a few small=
 changes:
>>=20
>> 1. Allow zero sized arrays in C++.
>>=20
>> No code would break by just allowing something previously forbidden. The=
 problem with allowing this could have been to make up ones mind about what=
 size such an array should report.
>>=20
>> 2. Define that a zero size array occupies zero bytes.
>>=20
>> As zero size arrays have never been allowed in C++ it can't be a breakin=
g change to define that the now allowed zero size arrays actually consume n=
o bytes regardless of the size of the element.
>=20
> So you want
>=20
> struct Foo
> {
>    char array[0];
>    int value;
> };
>=20
> to be well-formed?
>=20
> That's problematic for a number of reasons.

Could you elaborate?

> --=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=
 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/isoc=
pp.org/d/msgid/std-proposals/CALnjya-8Kn7VR3J0yxfPoR%2BzpDGDNxXSUwh4ZpD-t1K=
dbN9Prw%40mail.gmail.com.

--=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/DA1D891D-5D63-44A8-BA31-A8D9BCC9E684%40gmail.com=
..

--Apple-Mail-9097D46E-DDCE-45CF-ACDC-74A4191AF82A
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div><br>On 6=
 Jul 2016, at 13:06, Mathias Gaunard &lt;<a href=3D"mailto:mathias@gaunard.=
com">mathias@gaunard.com</a>&gt; wrote:<br><br></div><blockquote type=3D"ci=
te"><div><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_qu=
ote">On 4 July 2016 at 16:15, Bengt Gustafsson <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:bengt.gustafsson@beamways.com" target=3D"_blank">bengt.gustafss=
on@beamways.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr"><div>I have been following the recent thread about empty base=
 optimization, or rather, the lack of empty member optimization possibility=
.. And today I again fell in the 0 sized array trap in metaprogramming, noti=
cing that it creates quite a few problems requiring extra coding.</div><div=
><br></div><div>This idea struck me to solve both of these issues at once b=
y a few small changes:</div><div><br></div><div>1. Allow zero sized arrays =
in C++.</div><div><br></div><div>No code would break by just allowing somet=
hing previously forbidden. The problem with allowing this could have been t=
o make up ones mind about what size such an array should report.</div><div>=
<br></div><div>2. Define that a zero size array occupies zero bytes.</div><=
div><br></div><div>As zero size arrays have never been allowed in C++ it ca=
n't be a breaking change to define that the now allowed zero size arrays ac=
tually consume no bytes regardless of the size of the element.</div></div><=
/blockquote><div><br></div><div>So you want<br><br></div><div>struct Foo</d=
iv><div>{</div><div>&nbsp; &nbsp;char array[0];</div><div>&nbsp; &nbsp;int =
value;</div><div>};</div><div><br></div><div>to be well-formed?<br><br>That=
's problematic for a number of reasons.</div></div></div></div></div></bloc=
kquote><div><br></div><div>Could you elaborate?</div><br><blockquote type=
=3D"cite"><div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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/CALnjya-8Kn7VR3J0yxfPoR%2BzpDGDNxXSUw=
h4ZpD-t1KdbN9Prw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALnjya-8Kn=
7VR3J0yxfPoR%2BzpDGDNxXSUwh4ZpD-t1KdbN9Prw%40mail.gmail.com</a>.<br>
</div></blockquote></body></html>

<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/DA1D891D-5D63-44A8-BA31-A8D9BCC9E684%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/DA1D891D-5D63-44A8-BA31-A8D9BCC9E684%=
40gmail.com</a>.<br />

--Apple-Mail-9097D46E-DDCE-45CF-ACDC-74A4191AF82A--

.
