From: David Given <dg@cowlark.com>
To: linux-sparse@vger.kernel.org
Subject: Re: Pointer arithmetic error
Date: Fri, 27 Jun 2008 15:03:08 +0100 [thread overview]
Message-ID: <4864F31C.3090606@cowlark.com> (raw)
In-Reply-To: <1214565644.20755.80.camel@tara.firmix.at>
Bernd Petrovitsch wrote:
> It is done IMHO with the false knowledge that "sizeof(int) == 4 *
> sizeof(char)".
No, it's correctly been told that ints are 32 bits wide, but then it's
converting this to *bytes* (not chars) by dividing by the hard-coded
constant 8.
(By 'byte' I'm referring to the quantum of addressingness of the
underlying machine architecture. In other words, the numbers that are
used as parameters as offsets into load and store. This isn't something
that's exposed to C except on architectures where sizeof(byte) ==
sizeof(char), i.e., all sensible ones.)
[...]
> ACK. Therefore "sizeof(char) == 1" must always hold.
Yes; but that is only true from C's perspective.
We're dealing with things from the machine code perspective, where
sizeof(byte) == 1, and sizeof(char) is not necessarily the same as
sizeof(byte).
I find it really helps with this stuff if you are capable of holding two
completely contradictory beliefs at the same time. A certain level of
insanity can help too...
--
David Given
dg@cowlark.com
next prev parent reply other threads:[~2008-06-27 14:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-26 23:40 Pointer arithmetic error David Given
2008-06-26 23:51 ` Chris Li
2008-06-27 0:17 ` David Given
2008-06-27 9:00 ` Christopher Li
2008-06-27 9:49 ` Bernd Petrovitsch
2008-06-27 10:55 ` David Given
2008-06-27 11:20 ` Bernd Petrovitsch
2008-06-27 14:03 ` David Given [this message]
2008-06-27 14:45 ` Bernd Petrovitsch
2008-06-27 15:45 ` David Given
2008-06-27 18:01 ` Christopher Li
2008-06-27 23:32 ` David Given
2008-06-28 0:17 ` Christopher Li
2008-06-28 0:23 ` David Given
2008-06-29 0:10 ` David Given
2008-06-28 0:29 ` Josh Triplett
2008-06-29 0:13 ` Tommy Thorn
[not found] ` <48658B28.6010301@numba-tu.com>
2008-06-29 0:30 ` David Given
2008-06-29 0:38 ` Tommy Thorn
2008-06-29 12:19 ` Bernd Petrovitsch
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=4864F31C.3090606@cowlark.com \
--to=dg@cowlark.com \
--cc=linux-sparse@vger.kernel.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 NNTP newsgroup(s).