This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy to an unaligned address
- From: Shaun Jackman <sjackman at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Ian Lance Taylor <ian at airs dot com>, Andrew Pinski <pinskia at physics dot uc dot edu>, Mike Stump <mrs at apple dot com>, Dave Korn <dave dot korn at artimi dot com>, Paul Koning <pkoning at equallogic dot com>, gcc at sources dot redhat dot com
- Date: Wed, 3 Aug 2005 12:15:05 -0600
- Subject: Re: memcpy to an unaligned address
- References: <200508022037.j72Kbr4T012558@earth.phy.uc.edu> <m3mzo0jcfm.fsf@gossamer.airs.com> <20050803180011.GA16808@redhat.com>
- Reply-to: Shaun Jackman <sjackman at gmail dot com>
On 8/3/05, Richard Henderson <rth@redhat.com> wrote:
> It is nevertheless correct. Examine all of the parts of the expression.
>
> In particular, "&s->b". What type does it have? In an ideal world, it
> would be "pointer to unaligned integer". But we have no such type in
> our type system, so it is "pointer to integer". This expression is ONLY
> THEN passed to memcpy. At which point we query the argument for its
> alignment, and get the non-intuitive result.
>
> If you instead pass "s" to memcpy, you should get the correct unaligned
> copy. If that isn't happening, that's a bug.
I'm not sure I understood the last line. s is a structure, and its
address is aligned. How would you pass it to memcpy, and why would it
generate an unaligned copy?
Cheers,
Shaun