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: Documentation for __aligned__ out of date?


Daniel Jacobowitz wrote:
drow@nevyn:/big/codesourcery% echo 'int x __attribute__((__aligned__(1)));' >qqqq.c
        .comm   x,4,1

That is a bug in the implementation of the aligned attribute. Apparently one that has been around for a long time unnoticed. I tried 2.8.1 and it fails there also.


If you try this with a structure type, you will see that it works as documented.

The reason for not letting aligned decrease alignment is because that will result in code that will fail on any target that requires aligned memory references. The only way that we can support unaligned memory references is with the packed attribute, so we allow one to reduce alignment only if packed is used. If you want to reduce alignment to 1, you use packed by itself. If you want to reduce alignment to a value other than 1, then you use packed in conjunction with aligned.

One might ask why the aligned attribute doesn't give a warning when you give a too small value. I think the reasoning here is that you only used aligned when you want a minimum alignment, and if the target happens to give you a larger alignment, then there is no problem, and hence no need to give a warning or error. If you want a specific alignment, then you have to use packed with or without aligned.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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