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: strict aliasing question



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.






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