This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/20794] [4.0/4.1 Regression] Miscompilation with __attribute ((aligned))
- From: "jsm28 at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Apr 2005 16:15:50 -0000
- Subject: [Bug middle-end/20794] [4.0/4.1 Regression] Miscompilation with __attribute ((aligned))
- References: <20050406144601.20794.jakub@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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