From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
linux-kernel@vger.kernel.org, gcc@gcc.gnu.org,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: ARM unaligned MMIO access with attribute((packed))
Date: Wed, 2 Feb 2011 17:39:32 +0000 (UTC) [thread overview]
Message-ID: <Pine.LNX.4.64.1102021728350.18796@digraph.polyomino.org.uk> (raw)
In-Reply-To: <AANLkTin6qEeN7XZuwePNWqS8i_aDY586V+sOqgD5pPQA@mail.gmail.com>
On Wed, 2 Feb 2011, Richard Guenther wrote:
> The pointer conversions already invoke undefined behavior as specified by the
> C standard (6.3.2.3/7).
I would say: the conversions are undefined if the pointer is
insufficiently aligned for any of the pointer types involved (source,
destination or intermediate), where the appropriate alignment for a packed
type is 1. Thus, the conversion from packed to non-packed is OK iff the
pointer target is sufficiently aligned for the non-packed type.
In general from a sequence of casts the compiler is permitted to deduce
that the pointer is sufficiently aligned for whatever type in the sequence
has the greatest alignment requirement (the middle-end may not have that
information at present, but the front end could insert some form of
alignment assertion if useful for optimization). *But* that is what is
permitted in standards terms; it is not necessarily safe in practice. In
particular, on non-strict-alignment targets such as x86 people do in
practice assume that unaligned accesses are OK at the C level, not just
the assembly level (glibc does so, for example), so it might be a bad idea
to assume alignment in a way that would cause that to break.
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2011-02-02 17:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-02 16:00 Arnd Bergmann
2011-02-02 16:37 ` Russell King - ARM Linux
2011-02-02 17:39 ` Arnd Bergmann
2011-02-02 19:14 ` Ian Lance Taylor
2011-02-02 21:38 ` David Miller
2011-02-02 21:45 ` Russell King - ARM Linux
2011-02-02 21:59 ` David Miller
2011-02-02 23:08 ` Måns Rullgård
2011-02-02 23:23 ` David Miller
2011-02-03 9:26 ` Arnd Bergmann
2011-02-03 15:03 ` Arnd Bergmann
2011-02-02 16:51 ` Richard Guenther
2011-02-02 17:09 ` Russell King - ARM Linux
2011-02-02 17:39 ` Joseph S. Myers [this message]
2011-04-26 15:00 ` Rabin Vincent
2011-04-26 18:51 ` Alan Stern
2011-04-27 14:06 ` Rabin Vincent
2011-04-27 16:25 ` Alan Stern
2011-04-27 16:37 ` Arnd Bergmann
2011-04-28 13:35 ` Alan Stern
2011-04-28 14:16 ` Arnd Bergmann
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.64.1102021728350.18796@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=arnd@arndb.de \
--cc=gcc@gcc.gnu.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.maydell@linaro.org \
--cc=richard.guenther@gmail.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
all inboxes | Powered by JetHome®