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: C ABI: struct/union inconsistency


On Fri, Sep 27, 2002 at 10:21:59AM -0700, Mark Mitchell wrote:
> I must say that I'm concerned about the fact that things like:
> 
>  struct S s[3];
> 
>  ... sizeof (s) / sizeof (S) ...
> 
> won't work, and that s[0] and s[1] have the same address.

Yeah, well... caveat programmer.

We could perhaps prevent zero sized structures from being put into
arrays.  We should look to see if that ever happens in existing code
first though.

> That means we lose C/C++ compatibility even for a type which is in
> the common subset of both languages.

Compatibility between C and C++ is interesting from a data sharing
standpoint.  Empty classes contain no data to be shared, ergo are
not interesting.

> Perhaps we should offer a switch and/or attribute to control this
> behavior?

I don't think that's worth the bother.

> That sounds, then, like an agreement to change the alignment of the
> union example to match the struct example?

Yes.


r~


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