From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2157 invoked by alias); 9 Dec 2004 20:20:55 -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 2053 invoked from network); 9 Dec 2004 20:20:46 -0000 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 9 Dec 2004 20:20:46 -0000 Received: (qmail 15038 invoked from network); 9 Dec 2004 20:20:45 -0000 Received: from localhost (HELO digraph.polyomino.org.uk) (joseph@127.0.0.1) by mail.codesourcery.com with DES-CBC3-SHA encrypted SMTP; 9 Dec 2004 20:20:45 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.42) id 1CcUmJ-0001T6-B3; Thu, 09 Dec 2004 20:20:43 +0000 Date: Thu, 09 Dec 2004 20:20:00 -0000 From: "Joseph S. Myers" X-X-Sender: jsm28@digraph.polyomino.org.uk To: Steve Ellcey cc: gcc@gcc.gnu.org Subject: Re: memcpy / Language Lawyer / optimization question In-Reply-To: <200412091932.LAA06762@hpsje.cup.hp.com> Message-ID: References: <200412091932.LAA06762@hpsje.cup.hp.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2004-12/txt/msg00337.txt.bz2 On Thu, 9 Dec 2004, Steve Ellcey wrote: > My question is about the second memcpy where I cast to (void *). This > still results in an abort on IA64 because it is still assuming integer > alignment (and thus changing the code to do an integer assignment). Is > it legal to do this transformation with the (void *) cast? The casts in the calls to memcpy are irrelevant: the undefined behavior occurs before them, at the point where you cast an unaligned pointer to int *. Casting a pointer to another pointer type for which it doesn't have the alignment yields undefined behavior. The compiler can assume that the result of a sequence of pointer casts has the alignment of whichever type in the sequence of pointer types has the strictest alignment requirements. -- Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/ jsm@polyomino.org.uk (personal mail) joseph@codesourcery.com (CodeSourcery mail) jsm28@gcc.gnu.org (Bugzilla assignments and CCs)