strict aliasing question

Dale Johannesen dalej@apple.com
Sun Nov 12 08:16:00 GMT 2006


On Nov 11, 2006, at 10:45 PM, Howard Chu wrote:

> Andrew Pinski wrote:
>> On Sat, 2006-11-11 at 22:18 -0800, Ian Lance Taylor wrote:
>>
>>> Your code will be safe on all counts if you change buf from int[] to
>>> char[].  The language standard grants a special exemption to char*
>>> pointers.  Without that exemption, it would be impossible to write
>>> malloc in C.
>>>
>
> As I recall, we chose int[] for alignment reasons, figuring we'd  
> have no guarantees on the alignment of a char[].

True, but add __attribute__((aligned(4))) and all is well.






More information about the Gcc mailing list