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: misaligned access


Mike Stump wrote:

> > 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.
>

Well, of course....  ;)


>
> 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.  :-(
>

Yes, I suggested the memcpy solution to the guy who _actually_ has the
problem (my very original posting was on his behalf)...  He that would be
to (time) inefficient.. But smart as he is.... I couldn't convince him
that 3 shifts and 4 load/stores for EVERY variable access in his program
is even *MORE* inefficient...




>
> Thanks for sharing your solution.

    Oh sure... I'm just glad this solution will now be found when someone
searches in the archives for "misalign" (which is what I did some time
ago)

-- Davy




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