Document empty structures
Richard Earnshaw
rearnsha@arm.com
Mon Apr 14 18:52:00 GMT 2003
>
> 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?
Not a patch, but it seems that this is the bit of code that handles this
case:
cp/class.c:
/* Make sure not to create any structures with zero size. */
if (integer_zerop (rli_size_unit_so_far (rli)) && CLASSTYPE_EMPTY_P (t))
place_field (rli,
build_decl (FIELD_DECL, NULL_TREE, char_type_node));
so we behave as though the class contained a single anonymous char member.
R.
More information about the Gcc-patches
mailing list