[PATCH] Introduce __BIGGEST_ALIGNMENT__ macro

Jonathan Roelofs jonathan at codesourcery.com
Sat Dec 13 14:26:00 PST 2014



On 12/13/14 2:32 PM, Joerg Sonnenberger wrote:
> On Sat, Dec 13, 2014 at 09:15:53PM +0000, mats petersson wrote:
>> So, what kind of documentation would you like to see?
>>
>> The GCC docs here:
>> https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
>>
>> say: GCC also provides a target specific macro __BIGGEST_ALIGNMENT__, which
>> is the largest alignment ever used for any data type on the target machine
>> you are compiling for.
>
> How does that interact with codegen flags like -mno-sse2? What about
> support for new target types in later version -- from the writing it is
> nowhere clear that this macro is not fixed.
The gcc page on it says that it *can* change with codegen flags, and I agree, it 
says nothing about when it will change, nor how flags affect it.

Given that, my feeling is that Mats' intent on use of this macro is wrong. 
__BIGGEST_ALIGNMENT__ should be used in the same way that the int*_fast_t types 
are: where you don't care about the actual alignment, but you just want an 
alignment that is 'fast' on the platform.


"we discussed some code that had accidentally aligned it's sub-allocated block 
to 4 bytes for a 64-bit type, and got a unaligned access trap."

For that, you should probably be using __alignof__.


Jon

>
> Joerg
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-commits mailing list