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]

Re: arm.md: arm_arch4 & LDRH vs LDRB


Hi Igor,

: I tried to compile following example:
: 
: typedef unsigned short __attribute__ ((aligned(1))) *tpShort;
: tpShort qx;
: 
: unsigned short i;
: 
: void module1(void)
: {
:   i = *qx;
: }

This will not work.  The 'aligned' attribute can only be used to
increase the alignment of a type or variable, it cannot be used to
decrease it.  Note, despite what the documentation in extend.texi may 
imply, you cannot use the packed attribute to fix things up either.

Basically GCC does not (currently) support unaligned pointers.

If you have a situation where you belive that a pointer may be
unaligned you will have to code around it.  A union with char and
short fields in it would be my recommendation.

Cheers
	Nick


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