From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] packed attribute problem
Date: Mon, 11 Oct 2010 13:32:42 +0200 [thread overview]
Message-ID: <m24octge1x.fsf@ohwell.denx.de> (raw)
In-Reply-To: <20101007151537.23984e0d@udp111988uds.am.freescale.net> (Scott Wood's message of "Thu, 7 Oct 2010 15:15:37 -0500")
Hi Scott,
> On Thu, 7 Oct 2010 21:31:43 +0200
> Wolfgang Denk <wd@denx.de> wrote:
>
>> Dear Scott Wood,
>>
>> In message <20101007135257.05a93975@udp111988uds.am.freescale.net> you wrote:
>> >
>> > > It is a pretty common method to use a pointer to some struct (for
>> > > example, some form of PDU) and make it point to some I/O buffer.
>> >
>> > Yes, but at that point we are not talking about well-defined C, but
>> > rather implementation-specific behavior. There's nothing wrong with
>> > it, but the C standard is no longer authoritative on what happens in
>> > such cases.
>>
>> Huch? Which part of that is not well-defined (or even not
>> standard-conforming) C?
>
> Well, how do you obtain the unaligned pointer?
[...]
> Extensions like __attribute__((packed)) are obviously not
> well-defined C.
In ISO-IEC9899:TC3[1] I find this about dereferencing a pointer:
,----[ 6.5.3.2 footnote 87 ]
| [...]
| Among the invalid values for dereferencing a pointer by the unary *
| operator are a null pointer, an address inappropriately aligned for the
| type of object pointed to, and the address of an object after the end of
| its lifetime.
`----
So dereferencing such a pointer - however we arrive at it - is simply
invalid. The same sentence is in the ANSI spec[2] also. The C FAQ[3]
notes in section 16.8 that using unaligned pointers may very well lead
to segmentation faults, bus errors or general protection faults. Not
much documentation actually...
Cheers
Detlev
[1] http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
[2] http://flash-gordon.me.uk/ansi.c.txt
[3] http://www.c-faq.com/versions.html
--
... the tools we are trying to use and the language or notation we are using to
express or record our thoughts, are the major factors determining what we can
think or express at all!
-- Edsger W. Dijkstra
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
next prev parent reply other threads:[~2010-10-11 11:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 9:38 [U-Boot] packed attribute problem Vipin Kumar
2010-10-04 10:17 ` Wolfgang Denk
2010-10-04 10:30 ` Vipin Kumar
2010-10-04 10:44 ` Wolfgang Denk
2010-10-04 10:56 ` Reinhard Meyer
2010-10-04 11:01 ` Vipin Kumar
2010-10-04 11:46 ` Reinhard Meyer
2010-10-04 12:29 ` Wolfgang Denk
2010-10-04 12:43 ` Reinhard Meyer
2010-10-04 12:50 ` Balau
2010-10-04 12:58 ` Wolfgang Denk
2010-10-04 13:02 ` [U-Boot] DDR SPD table sywang
2010-10-04 15:56 ` Mike Frysinger
2010-10-04 12:56 ` [U-Boot] packed attribute problem Wolfgang Denk
2010-10-05 3:45 ` Vipin Kumar
2010-10-05 11:43 ` Detlev Zundel
2010-10-05 18:03 ` Scott Wood
2010-10-07 9:59 ` Detlev Zundel
2010-10-07 16:46 ` Scott Wood
2010-10-07 17:57 ` Wolfgang Denk
2010-10-07 18:52 ` Scott Wood
2010-10-07 19:31 ` Wolfgang Denk
2010-10-07 20:15 ` Scott Wood
2010-10-11 11:32 ` Detlev Zundel [this message]
2010-10-11 13:22 ` Balau
2010-10-04 10:57 ` Vipin Kumar
2010-10-04 12:04 ` Wolfgang Denk
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=m24octge1x.fsf@ohwell.denx.de \
--to=dzu@denx.de \
--cc=u-boot@lists.denx.de \
/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