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: 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


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