This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: attribute "unpadded"
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Paul Koning <pkoning at equallogic dot com>,"aoliva at redhat dot com" <aoliva at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 26 Aug 2002 00:58:08 -0000
- Subject: Re: RFC: attribute "unpadded"
I like that. The "unpadded" proposal sounded like it would do
significant violence to the C type system, and this avoids that
issue.
Alexandre's proposal doesn't work very well. The size of a type
is an important property of the type; with Alexandre's proposal
"the same" type has different sizes depending on context.
Consider, for example:
struct A { ... };
struct B { A a __attribute___((unpadded)); };
(This is Alexandre's suggestion.)
Now:
struct B b;
struct A a;
A* ap = &b.a;
*ap = a;
Or, even:
memcpy (ap, &a, sizeof (struct A));
My proposal doesn't "do violence" to the type system; it simply
adds a class of types for which certain actions are not allowed,
such as the creation of arrays of these types.
My proposal is the right way (in a type-theoretic sense) to do
the extension.
If we don't want the extension, we can decide not to have it.
We will suffer since people who want to build C++-compatible
data structures in other languages will have no way to do it.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com