This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Document empty structures
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Richard dot Earnshaw at arm dot com
- Cc: Geoffrey Keating <geoffk at apple dot com>, Fergus Henderson <fjh at cs dot mu dot OZ dot AU>, Geoffrey Keating <gkeating at apple dot com>, gcc-patches at gcc dot gnu dot org
- Date: 14 Apr 2003 19:47:45 -0700
- Subject: Re: Document empty structures
- Organization: CodeSourcery, LLC
- References: <200304141851.h3EIpcS30209@pc960.cambridge.arm.com>
On Mon, 2003-04-14 at 11:51, Richard Earnshaw wrote:
> >
> > On Monday, April 14, 2003, at 11:20 AM, Mark Mitchell wrote:
> >
> > > On Mon, 2003-04-14 at 11:17, Richard Earnshaw wrote:
> > >>
> > >>>> I'm pretty sure that the C++ language standard does not say that
> > >>>> empty
> > >>>> structures have size 1 -- AFAIK it just says that they have
> > >>>> non-zero size
> > >>>> (C++98 section 9, paragraph 3).
> > >>>
> > >>> Correct. The C++ ABI says they have size 1.
> > >>
> > >> Even on a machine where STRUCTURE_SIZE_BOUNDARY != 8? I would have
> > >> thought STRUCTURE_SIZE_BOUNDARY / BITS_PER_UNIT was a more sensible
> > >> definition.
> > >
> > > You are even more correct. I forget what the exact calculation is, but
> > > it does indeed take this kind of thing into account.
> >
> > Could someone provide a patch?
I checked in this patch, tested by rebuilding the docs.
--
Mark Mitchell <mark at codesourcery dot com>
CodeSourcery, LLC
2003-04-14 Mark Mitchell <mark at codesourcery dot com>
* doc/extend.texi (Empty Structures): Correct description of G++'s
handling of these structures.
Index: extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.133
diff -c -5 -p -r1.133 extend.texi
*** extend.texi 14 Apr 2003 02:55:27 -0000 1.133
--- extend.texi 15 Apr 2003 02:27:36 -0000
***************
*** 1,6 ****
! @c Copyright (C) 1988,1989,1992,1993,1994,1996,1998,1999,2000,2001,2002,
@c 2003 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@node C Implementation
--- 1,6 ----
! @c Copyright (C) 1988,1989,1992,1993,1994,1996,1998,1999,2000,2001,2002, 2003,
@c 2003 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@node C Implementation
*************** GCC permits a C structure to have no mem
*** 1370,1380 ****
struct empty @{
@};
@end example
The structure will have size zero. In C++, empty structures are part
! of the language, and the language standard says they have size 1.
@node Variable Length
@section Arrays of Variable Length
@cindex variable-length arrays
@cindex arrays of variable length
--- 1370,1381 ----
struct empty @{
@};
@end example
The structure will have size zero. In C++, empty structures are part
! of the language. G++ treats empty structures as if they had a single
! member of type @code{char}.
@node Variable Length
@section Arrays of Variable Length
@cindex variable-length arrays
@cindex arrays of variable length