All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Given <dg@cowlark.com>
To: linux-sparse@vger.kernel.org
Subject: Re: Pointer arithmetic error
Date: Fri, 27 Jun 2008 16:45:57 +0100	[thread overview]
Message-ID: <48650B35.5040505@cowlark.com> (raw)
In-Reply-To: <1214577926.20755.98.camel@tara.firmix.at>

Bernd Petrovitsch wrote:
[...]
> That's the bug. there is no difference between "byte" and "char". Tell
> it that a char has 32 bits too *if* it's the case.

Having checked the standard it turns out that we've been talking at 
cross purposes as I've been using the wrong terminology --- it actually 
defines (unhelpfully) that byte and char are the same size. Sorry for 
the confusion.

What I was referring to when I previously said (erroneously) 'byte' was 
'an address delta of 1', as understood by the assembler. Let's just call 
this a 'unit' for clarity. This is not necessarily the same size as a char.

[...]
>>> ACK. Therefore "sizeof(char) == 1" must always hold.
>> Yes; but that is only true from C's perspective.
> 
> Is there another remotely relevant perspective (let alone more
> important) in a C parser?

The issue here is that sparse is not just a C parser. It is also a 
compiler, and needs to know how to manipulate addresses that are 
represented as units. (This is why I'm using it for my project.) It has 
to be able to express an offset into a structure in units to pass on to 
the 'assembler' (with stock sparse, this is the human who's reading the 
output of test-linearise).

Currently I believe that some parts of sparse are assuming that a unit 
is 8 bits, and other parts are assuming that a unit is CHAR_BITS bits, 
neither of which is necessarily correct. However, I need to go and check 
up on this; I'm away from the machine with my project on it right now.

I'm proposing adding a bits_in_unit (or something) setting and then 
going through and tracking down these places and changing them to use 
it. That way it should still work fine on exotic architectures like mine.

(Wikipedia has a rather interesting table of machines with interesting 
word/byte/char sizes:

http://en.wikipedia.org/wiki/Word_(computing)#Table_of_word_sizes

The last machine with a freaky word size was the Cray C-90 in 1991, 
where a unit was 64 bits but a char was 8 bits...)

-- 
David Given
dg@cowlark.com

  reply	other threads:[~2008-06-27 15:46 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
2008-06-27 14:45             ` Bernd Petrovitsch
2008-06-27 15:45               ` David Given [this message]
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=48650B35.5040505@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.