----Original Message----
>From: Shaun Jackman
>Sent: 02 August 2005 18:33

> In a typical Ethernet/IP ARP header the source IP address is
> unaligned. Instead of using...
>       out->srcIPAddr = in->dstIPAddr;
> ... I used...
>       memcpy(&out->srcIPAddr, &in->dstIPAddr, sizeof(uint32_t));
> ... to account for the unaligned destination. This worked until gcc 4,
> which now generates a simple load/store.
>       ldr     r3, [r6, #24]
>       adds    r2, r4, #0
>       adds    r2, #14
>       str     r3, [r2, #0]
> A nice optimisation, but in this case it's incorrect. $r4 is aligned,
> and the result of adding #14 to $r4 is an unaligned pointer.
> 
> Should gcc know better, or do I need to give it a little more
> information to help it out?

  In order for anyone to answer your questions about the alignment of
various types in a struct, don't you think you should perhaps have told us a
little about what those types actually are and how the struct is laid out?
[*]


    cheers,
      DaveK

[*] - See debugging, psychic ;)
-- 
Can't think of a witty .sigline today....

Reply via email to