misaligned access
Mike Stump
mrs@windriver.com
Wed Dec 13 09:46:00 GMT 2000
> Date: Wed, 13 Dec 2000 11:09:30 -0600
> From: Davy Durham <david.durham@wcom.com>
> To: gcc@gcc.gnu.org
> And I can point a foo * anywhere to any address not aligned i.e.
> anywhere in the buffer'o'data... And I don't get a bus error on
> sparc.... I tested it..
The only issue, which I am sure you already know about, but I mention
it for others that might not know, packing does change the structure
layout, so you have to be sure the start address of each element you
want to get at, is at the right place.
Also, you could also memcpy to a suitably aligned location, and then
use it out of there. And last, ABI compatibility across platforms
with structures can be problematic (non-portable). gcc needs a way to
have a machine and platform independent layout format and expose that
to the C programmer. Programmers already do this, and already expect
it to work. :-(
Thanks for sharing your solution.
More information about the Gcc
mailing list