From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26499 invoked by alias); 3 Aug 2005 18:15:15 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26461 invoked by uid 22791); 3 Aug 2005 18:15:10 -0000 Received: from rproxy.gmail.com (HELO rproxy.gmail.com) (64.233.170.199) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 03 Aug 2005 18:15:10 +0000 Received: by rproxy.gmail.com with SMTP id a36so244443rnf for ; Wed, 03 Aug 2005 11:15:05 -0700 (PDT) Received: by 10.11.88.54 with SMTP id l54mr5723cwb; Wed, 03 Aug 2005 11:15:05 -0700 (PDT) Received: by 10.11.99.47 with HTTP; Wed, 3 Aug 2005 11:15:05 -0700 (PDT) Message-ID: <7f45d93905080311152d530172@mail.gmail.com> Date: Wed, 03 Aug 2005 18:15:00 -0000 From: Shaun Jackman Reply-To: Shaun Jackman To: Richard Henderson Subject: Re: memcpy to an unaligned address Cc: Ian Lance Taylor , Andrew Pinski , Mike Stump , Dave Korn , Paul Koning , gcc@sources.redhat.com In-Reply-To: <20050803180011.GA16808@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200508022037.j72Kbr4T012558@earth.phy.uc.edu> <20050803180011.GA16808@redhat.com> X-SW-Source: 2005-08/txt/msg00123.txt.bz2 On 8/3/05, Richard Henderson wrote: > It is nevertheless correct. Examine all of the parts of the expression. >=20 > 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. >=20 > 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