public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Steve Ellcey <sje@cup.hp.com>
Cc: gcc@gcc.gnu.org
Subject: Re: memcpy / Language Lawyer / optimization question
Date: Thu, 09 Dec 2004 20:20:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0412092017440.5206@digraph.polyomino.org.uk> (raw)
In-Reply-To: <200412091932.LAA06762@hpsje.cup.hp.com>

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)

  parent reply	other threads:[~2004-12-09 20:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09 19:33 Steve Ellcey
2004-12-09 19:41 ` Joe Buck
2004-12-09 19:52   ` Paul Jarc
2004-12-09 20:11 ` Gabriel Dos Reis
2004-12-09 20:14 ` Joe Buck
2004-12-09 20:20 ` Joseph S. Myers [this message]
2004-12-10 16:51   ` Steve Ellcey
2004-12-09 22:54 Paul Schlie
2004-12-09 23:36 ` Geoffrey Keating
2004-12-09 23:53 ` Joe Buck
2004-12-10  3:18   ` Paul Schlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0412092017440.5206@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=sje@cup.hp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).