From: Paul Schlie <schlie@comcast.net>
To: <gcc@gcc.gnu.org>
Subject: Re: memcpy / Language Lawyer / optimization question
Date: Thu, 09 Dec 2004 22:54:00 -0000 [thread overview]
Message-ID: <BDDE41C0.82F2%schlie@comcast.net> (raw)
> Joseph S. Myers wrote:
>> 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.
As a more general but related question: as C does not define/specify
everything, and even occasionally specifies something as being explicitly
"unspecified", giving license to the complier to express whatever incidental
behavior it may have; has the GCC team adopted the strategy that it will
strive to adopt and document the behavior which seems most generally useful
and/or least-fragile in such circumstances (which it has license to do), as
opposed to justifying any such behavior as being "legal" without regard to
the consideration of adopting a more useful behavior, and/or emit warnings
if the adopted behavior may have undesirable consequences when reasonable
to do so; or is this also "unspecified"? :)
next reply other threads:[~2004-12-09 22:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-09 22:54 Paul Schlie [this message]
2004-12-09 23:36 ` Geoffrey Keating
2004-12-09 23:53 ` Joe Buck
2004-12-10 3:18 ` Paul Schlie
-- strict thread matches above, loose matches on Subject: below --
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
2004-12-10 16:51 ` Steve Ellcey
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=BDDE41C0.82F2%schlie@comcast.net \
--to=schlie@comcast.net \
--cc=gcc@gcc.gnu.org \
/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).