220 26589 <CALnjya-8Kn7VR3J0yxfPoR+zpDGDNxXSUwh4ZpD-t1KdbN9Prw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Mathias Gaunard <mathias@gaunard.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 13:06:33 +0100
Lines: 90
Approved: news@gmane.org
Message-ID: <CALnjya-8Kn7VR3J0yxfPoR+zpDGDNxXSUwh4ZpD-t1KdbN9Prw@mail.gmail.com>
References: <51e6aec9-a745-4fd9-94f7-bdd78b5798ca@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11401ac28ea1130536f66634
X-Trace: ger.gmane.org 1467806812 405 80.91.229.3 (6 Jul 2016 12:06:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 6 Jul 2016 12:06:52 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDCN3ZE6W4GRBS7I6O5QKGQEWHYLMKA@isocpp.org Wed Jul 06 14:06:38 2016
Return-path: <std-proposals+bncBDCN3ZE6W4GRBS7I6O5QKGQEWHYLMKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f69.google.com ([209.85.215.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDCN3ZE6W4GRBS7I6O5QKGQEWHYLMKA@isocpp.org>)
	id 1bKlbC-00085n-6a
	for gclcip-std-proposals@m.gmane.org; Wed, 06 Jul 2016 14:06:38 +0200
Original-Received: by mail-lf0-f69.google.com with SMTP id a2sf155990235lfe.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Jul 2016 05:06:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references: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=eKyL6JLsmjhOv+zV/JAjstFTPPveHZ9+ZPzhGaCI0SI=;
        b=zbOisI42mb8ft2c8tsEHvliCkZJFz7FH3/2WLVGqaCfgtMefEkZEmYm1jw7aYOCp+2
         4VGIgMlYBnRwUmKG5kafonaMc0rssfMuABysvkRhc1Pmiw+4elyJWV2T1QXyetM0Yx9G
         e2PQUl43xYQfVfuqL8fK1zMpfp/SZd+PSTf25aqB5PqLf5E4IG4Ka2JummXy4M4uITKy
         ZngYbpBonyRYKFDjxygJv8HFodoKzuE7NCdZZ0hvUV9rzDL6oTtCs4YFwnaIY7y0rAqB
         TpIrHngsfAi/wUHzqQmaL37yYjrlDZ5/5JUMwsEtYn/nDTgIlIeyvgJsi8hEsPgQBurr
         2c0A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references: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=eKyL6JLsmjhOv+zV/JAjstFTPPveHZ9+ZPzhGaCI0SI=;
        b=ZyCeCzOM/PU5Tr94nfOVCzlaLMZuwoP7FwLTt7JFrB/dUTtMZdQTGd5Cn6xX3mZQsl
         rnnvrEsw56B/0pKGCPEIggziYBif2M0SqaOOZ5dC4o4y8W24gBX3mW0zfnZLKIL5E0wi
         zbNfLdS1ML5GugiCiYMHa2dyaHarzTf1OwdInjt789jUQSxj20Z2zeBsai4XWNCXRbDY
         NVnLvLc8cpi6heFf8ELlIFAdHtDAu9dbQ6/3odTSQYZkHzE9TQVSi+veLqDAUZeG+Jw5
         Xk5YkMqJvsdDNZTve0ZDSENKHP0qFySaJXkIuOd0DzOlY8MdqcZKcs9YYAhrcRRhXC5T
         4k0w==
X-Gm-Message-State: ALyK8tIFSfhUZTlqR7FHV6w062PpKBraFsTMYUnxRi1w8wAHk2fDI33a2MmPWVW64cIx7w==
X-Received: by 10.46.32.71 with SMTP id g68mr7671517ljg.8.1467806796671;
        Wed, 06 Jul 2016 05:06:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.57.70 with SMTP id g67ls858773wma.2.canary; Wed, 06 Jul
 2016 05:06:35 -0700 (PDT)
X-Received: by 10.28.158.206 with SMTP id h197mr21965851wme.50.1467806795105;
        Wed, 06 Jul 2016 05:06:35 -0700 (PDT)
Original-Received: from 6.mo4.mail-out.ovh.net (6.mo4.mail-out.ovh.net. [188.165.36.253])
        by mx.google.com with ESMTPS id n4si140058wja.210.2016.07.06.05.06.35
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 06 Jul 2016 05:06:35 -0700 (PDT)
Received-SPF: pass (google.com: domain of mathias@gaunard.com designates 188.165.36.253 as permitted sender) client-ip=188.165.36.253;
Original-Received: from player735.ha.ovh.net (b9.ovh.net [213.186.33.59])
	by mo4.mail-out.ovh.net (Postfix) with ESMTP id C074A1024B38
	for <std-proposals@isocpp.org>; Wed,  6 Jul 2016 14:06:34 +0200 (CEST)
Original-Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44])
	(Authenticated sender: mathias@gaunard.com)
	by player735.ha.ovh.net (Postfix) with ESMTPSA id 8989B160080
	for <std-proposals@isocpp.org>; Wed,  6 Jul 2016 14:06:34 +0200 (CEST)
Original-Received: by mail-lf0-f44.google.com with SMTP id l188so153049642lfe.2
        for <std-proposals@isocpp.org>; Wed, 06 Jul 2016 05:06:34 -0700 (PDT)
X-Received: by 10.25.215.20 with SMTP id o20mr4565940lfg.18.1467806794028;
 Wed, 06 Jul 2016 05:06:34 -0700 (PDT)
Original-Received: by 10.25.87.141 with HTTP; Wed, 6 Jul 2016 05:06:33 -0700 (PDT)
In-Reply-To: <51e6aec9-a745-4fd9-94f7-bdd78b5798ca@isocpp.org>
X-Gmail-Original-Message-ID: <CALnjya-8Kn7VR3J0yxfPoR+zpDGDNxXSUwh4ZpD-t1KdbN9Prw@mail.gmail.com>
X-Ovh-Tracer-Id: 17602882097674106495
X-VR-SPAMSTATE: OK
X-VR-SPAMSCORE: 0
X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeltddrvdeigdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu
X-Original-Sender: mathias@gaunard.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of mathias@gaunard.com designates 188.165.36.253 as permitted sender) smtp.mailfrom=mathias@gaunard.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:26589
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26589>

--001a11401ac28ea1130536f66634
Content-Type: text/plain; charset=UTF-8

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, or
> rather, the lack of empty member optimization possibility. And today I
> again fell in the 0 sized array trap in metaprogramming, noticing that it
> creates quite a few problems requiring extra coding.
>
> This idea struck me to solve both of these issues at once by a few small
> changes:
>
> 1. Allow zero sized arrays in C++.
>
> 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.
>
> 2. Define that a zero size array occupies zero bytes.
>
> As zero size arrays have never been allowed in C++ it can't be a breaking
> change to define that the now allowed zero size arrays actually consume no
> bytes regardless of the size of the element.
>

So you want

struct Foo
{
   char array[0];
   int value;
};

to be well-formed?

That's problematic for a number of reasons.

-- 
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/CALnjya-8Kn7VR3J0yxfPoR%2BzpDGDNxXSUwh4ZpD-t1KdbN9Prw%40mail.gmail.com.

--001a11401ac28ea1130536f66634
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 4=
 July 2016 at 16:15, Bengt Gustafsson <span dir=3D"ltr">&lt;<a href=3D"mail=
to:bengt.gustafsson@beamways.com" target=3D"_blank">bengt.gustafsson@beamwa=
ys.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"><div dir=3D"=
ltr"><div>I have been following the recent thread about empty base optimiza=
tion, or rather, the lack of empty member optimization possibility. And tod=
ay I again fell in the 0 sized array trap in metaprogramming, noticing that=
 it creates quite a few problems requiring extra coding.</div><div><br></di=
v><div>This idea struck me to solve both of these issues at once by a few s=
mall 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 something prev=
iously forbidden. The problem with allowing this could have been to 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 can&#39;t b=
e a breaking change to define that the now allowed zero size arrays actuall=
y consume no bytes regardless of the size of the element.</div></div></bloc=
kquote><div><br></div><div>So you want<br><br></div><div>struct Foo</div><d=
iv>{</div><div>=C2=A0 =C2=A0char array[0];</div><div>=C2=A0 =C2=A0int value=
;</div><div>};</div><div><br></div><div>to be well-formed?<br><br>That&#39;=
s problematic for a number of reasons.</div></div></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/CALnjya-8Kn7VR3J0yxfPoR%2BzpDGDNxXSUw=
h4ZpD-t1KdbN9Prw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALnjya-8Kn7VR3=
J0yxfPoR%2BzpDGDNxXSUwh4ZpD-t1KdbN9Prw%40mail.gmail.com</a>.<br />

--001a11401ac28ea1130536f66634--

.
