This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use of VLA in struct in gcc-torture/execute/20020412-1.c


On 08-Sep-2002, Richard Henderson <rth@redhat.com> wrote:
> On Sun, Sep 08, 2002 at 03:14:02PM -0400, John David Anglin wrote:
> > Another question, what should FUNCTION_ARG do about arguments that have
> > a zero size (e.g., an empty struct, another GCC extension)?
> 
> A _fixed_ size zero?  I think we're supposed to treat 
> that as a struct of size one.  Look at x86 output to be sure.

Empty structs are not allowed in ISO C, but are allowed in both ISO C++
and GNU C.  Historically, the GNU C extension was first, I believe.
GNU C used size zero for empty structs.  C++, however, requires
all objects, even empty structs, to have a non-zero size.
So this is an area in which there is a conflict between the
GNU C ABI and the C++ ABI (and not just the ABIs -- it also
affects the APIs).

Empty structs are not used very much in C, so it might be wise to
change GNU C to have the same behaviour as ISO C++ here, even
though IMHO the GNU C behaviour is better.  However, this should
only be done if there is some way of modifying the source to
retain backwards binary compatibility for C, e.g. perhaps
attribute((packed)) on an empty struct could cause it to have
size zero rather than size one.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]