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]
Other format: [Raw text]

Re: memcpy to an unaligned address


On 8/2/05, Paul Koning <pkoning@equallogic.com> wrote:
> It sounds like the workaround is to avoid memcpy, and just use
> variable assignment.  Alternatively, cast the pointers to char*, which
> should force memcpy to do the right thing.  Ugh.

I swear originally, back in the gcc 2.95 days, I used memcpy because
the memcpy function checked for unaligned pointers, whereas storing to
and loading from unaligned variables generated a simple store/load
instruction which wouldn't work. It seems the tables have turned and
the exact opposite is true now with gcc 4, where memcpy doesn't work,
but unaligned variables do. I believe gcc 3 behaved the same as gcc 2
-- memcpy worked, unaligned variables didn't work. Can someone confirm
this summary is correct?

It seems to me there's an argument for a _memcpy_unaligned(3)
function, as ugly as that is.

Cheers,
Shaun


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