------- Additional Comments From jsm28 at gcc dot gnu dot org 2005-04-16 16:15 ------- Much the same issue can arise with array references through pointer-to-aligned-type, and with arithmetic on such pointers, as does with array-of-aligned-type. However, having extra alignment on a DECL, as opposed to on its type, doesn't cause problems.
The obvious options include: * Make a new type of larger size to match the alignment whenever e.g. an 8-byte-aligned-int is requested. (Probably breaks too much.) * Disallow arrays of extra-aligned types, and array references and pointer arithmetic on such types; either with an error, or with a warning and removal of the "aligned" attribute (in the case of arrays, attaching it to the array; in the case of pointers, causing the results of the arithmetic to have the ordinary type without alignment). We could also add a target_aligned attribute which can be used to describe the alignment of a pointer's target, to use for pointers to the start of an array where the start is aligned but the individual elements aren't. As well as allowing e.g. to define functions taking such pointer arguments, this would also allow refined rules: an array of an extra-aligned type has the alignment passed to the array (with a warning); pointers to extra-aligned types have the extra alignment removed from the target type in favour of a target_aligned attribute on the pointer; extra-aligned-array decays to target_aligned pointer; arithmetic on target_aligned pointers loses the target_aligned attribute unless GCC can prove that the value being added is a multiple of the extra alignment. I think this, properly implemented and ideally with the problems applying attributes to array parameters dealt with, would cover all the semantics people might want to specify except if they really do want alignment attributes to increase the size of the types being aligned. -- What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20794