This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: misaligned access
- To: david dot durham at wcom dot com, gcc at gcc dot gnu dot org
- Subject: Re: misaligned access
- From: Mike Stump <mrs at windriver dot com>
- Date: Wed, 13 Dec 2000 09:46:01 -0800 (PST)
> 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.