Subject: Re: Exactly what is wrong with our compiler?
To: David Laight <David.Laight@btinternet.com>
From: Todd Vierling <tv@wasabisystems.com>
List: port-sparc64
Date: 01/04/2002 13:10:39
On Fri, 4 Jan 2002, David Laight wrote:

: > memcpy (&data, buf + offset, sizeof (data));
: >
: > Note that gcc treats the use of memcpy and structure copies the same
: > way.
:
: I would have thought that memcpy( &data, ptr, sizeof data ) would be safe.
: Since there is an (implied) cast to void * in the function call.  If gcc's
: inlining of memcpy assumes otherwise it might be deemed broken.

No, because "ptr" in this context is a "struct ifreq *", not "void *".
The "implied" cast to "void *" is allowed to keep the compiler's notion of
alignment.  (This is in C99, but I believe this goes back further.)

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi & NetBSD:  Run with it.
-- CDs, Integration, Embedding, Support -- http://www.wasabisystems.com/