This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Should ADJUST_FIELD_ALIGN honor __attribute__((packed))?
- From: Daniel Jacobowitz <drow at false dot org>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 25 Mar 2004 15:42:31 -0500
- Subject: Should ADJUST_FIELD_ALIGN honor __attribute__((packed))?
Right now, if a target does not use MIN (myalign, computed) in every branch
of its ADJUST_FIELD_ALIGN, __attribute__((packed)) won't work right. For
instance, in rs6000/sysv4.h:
/* An expression for the alignment of a structure field FIELD if the
alignment computed in the usual way is COMPUTED. */
#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \
? 128 : COMPUTED)
This means that given the types (excuse my syntax, I haven't used AltiVec):
struct S1 {
char f;
int vec __attribute__((vector_size(16)));
};
struct S2 {
char f;
int vec __attribute__((vector_size(16)));
} __attribute__((packed));
struct S3 {
char f;
int vec __attribute__((vector_size(16),aligned(1)));
} __attribute__((packed));
structures S1 and S2 will have the same size, which hardly seems right.
Structure S3 will have a different size.
I suspect we should either fix all the copies of ADJUST_FIELD_ALIGN, or
guard calls with !DECL_PACKED. I'm not sure which. Any opinions?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer