This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy() inlining and alignment
- To: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Subject: Re: memcpy() inlining and alignment
- From: Jason Thorpe <thorpej at netbsd dot org>
- Date: Fri, 03 Mar 2000 18:03:55 -0800
- Cc: gcc-bugs at gcc dot gnu dot org, davem at redhat dot com, sommerfeld at netbsd dot org
- Reply-To: Jason Thorpe <thorpej at netbsd dot org>
On Sat, 4 Mar 2000 02:41:05 +0100
"Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> wrote:
> Since cp+1 is not correctly aligned 'struct s*', assigning it to src
> results in undefined behaviour. That, of course, does include the
> option of a later memcpy call crashing.
Okay, so what you're saying is that code that currently says this:
memcpy(&dst.i, &src->i, sizeof(dst.i));
should read:
memcpy(&dst.i, char_ptr_to_src + offsetof(struct s, i), sizeof(dst.i));
Ok, thanks for the dicussion, folks...
-- Jason R. Thorpe <thorpej@netbsd.org>