This is the mail archive of the gcc-bugs@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: memcpy() inlining and alignment


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>


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