Re: Pointer typecasts may write to incorrect addresses on ARM?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subramanyam Badri wrote:
> Hi,
>  
> I am using a GCC compiler for ARM and see an alignment problem with pointer typecasting.  We're porting code to ARM and found some writes to incorrect addresses.  Can you help?  For example:
>  
> char * pChar = (char *)0x100000;  /* hardcoded for example purposes */
> pChar[0] = 0x0;
> *(int *)&pChar[1] = 0x11223344;
>  
> /* We really want pChar[0] to equal 0x00, but it equals 0x44 on ARM!!!! */
> printf ("pChar[0] = 0x%02x\n", pChar[0]);
> 
> My understanding is that non-aligned memory access is allowed on ARM,

No, that's not true.  *Some* versions of ARM have some support for unaligned
memory accesses, some don't.  You need to be sure which one you've got.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux