This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy to an unaligned address
On Tue, Aug 02, 2005 at 02:29:44PM -0700, Mike Stump wrote:
> On Aug 2, 2005, at 1:45 PM, Ian Lance Taylor wrote:
> >That argument doesn't make sense to me. memcpy takes a void*
> >argument, which has no presumed alignment.
>
> The memcpy builtin uses the static type of the actual argument
> (before conversion to void*), to gain hints about the alignments of
> the data coming in. This is so that we can producing nice fast code
> for 1-16 bytes objects. This is actually good. The real problem is
> formation of the address of the member doesn't produce a pointer to
> unaligned type, but rather a pointer to aligned type, this is the
> part that is wrong. We'd have to add pointers to unaligned data to
> our type system to fix it. That should be done, but is a hard/big
> job, and no one has stepped forward to do it.
So my suggestion to just make pointers to unaligned objects void* would
work in this case, then.