From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <19f6168fb6b109424ddbb1d276d62e6b@brasstown.quanstro.net> Date: Sun, 1 Jul 2012 20:18:53 -0400 Message-ID: From: Comeau At9Fans To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=14dae9399cad2bbe2804c3cdbe8f Subject: Re: [9fans] cc nit? Topicbox-Message-UUID: a0dc1efc-ead7-11e9-9d60-3106f5b1d025 --14dae9399cad2bbe2804c3cdbe8f Content-Type: text/plain; charset=ISO-8859-1 On Sun, Jul 1, 2012 at 6:32 PM, Charles Forsyth wrote: > Yes, I was assuming the same approach as for the existing void data > declaration, that the structure is given a nominal size, > for just the reasons you give. (That's what gcc seems to do.) > > On 1 July 2012 23:22, Comeau At9Fans wrote: > >> Many compilers do just that, however, that said, unless the compiler is >> prepared for it, since it effectively yields a struct of zero size which >> normally is a no-go, it could produce bugs involving sizeof, initializers, >> pointer addition et al, even some divisions by zero if the compiler is >> making certain assumptions already, unless it already can have zero length >> objects of this nature for some other reasons. > > Actually gcc gives it (the empty struct) sizeof zero (same as for its zero length arrays). Comeau mimics that behavior in gcc-mode, but used to/still can also generate a dummy internal member too (usually a char bringing forth sizeof 1). -- Greg Comeau / 4.3.10.1 with C++0xisms now in beta! Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it? --14dae9399cad2bbe2804c3cdbe8f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sun, Jul 1, 2012 at 6:32 PM, Charles Forsyth <charles.forsyth@g= mail.com> wrote:
Yes, I was assuming the same approach as for the existing void data declara= tion, that the structure is given a nominal size,
for just the reasons = you give. =A0(That's what gcc seems to do.)

On 1 July 2012 23:22, Comeau At9Fans <comeauat9fans@gmail.com>= ; wrote:
Many compilers do just that, however, that said, unless the compiler is pre= pared for it, since it effectively yields a struct of zero size which norma= lly is a no-go, it could produce bugs involving sizeof, initializers, point= er addition et al, even some divisions by zero if the compiler is making ce= rtain assumptions already, unless it already can have zero length objects o= f this nature for some other reasons.

Actually gcc gives it (the empty struct) sizeof zero= (same as for its zero length arrays). =A0Comeau mimics that behavior in gc= c-mode, but used to/still can also generate a dummy internal member too (us= ually a char bringing forth sizeof 1).

--
Greg Comeau / 4.3.10.1 with C++0xisms now in bet= a!
Comeau C/C++ ONLINE =3D=3D> =A0 =A0 http://www.comeaucomputing.c= om/tryitout
World Class Compilers: =A0Breathtaking C++, Amazing C99, Fabulous C90.=
Comeau C/C++ with Dinkumware's Libraries... Have you tried i= t?

--14dae9399cad2bbe2804c3cdbe8f--