Linux SPARSE checker discussions
 help / color / mirror / Atom feed
From: Derek M Jones <derek@knosof.co.uk>
To: Morten Welinder <mwelinder@gmail.com>
Cc: Al Viro <viro@ftp.linux.org.uk>, linux-sparse@vger.kernel.org
Subject: Re: pointer arithmetics and casts
Date: Sat, 26 May 2007 04:32:47 +0100	[thread overview]
Message-ID: <4657AA5F.1020705@knosof.co.uk> (raw)
In-Reply-To: <118833cc0705251814h9fffa39xc4a0f3f9e61242b9@mail.gmail.com>

Morten,

>>         BINOP[+]
>>                 <tree for p>
>>                 BINOP[*]
>>                         IMPLICIEDT_CAST[ptrdiff_t]
>>                                 <tree for i>
>>                         VAL[sizeof(*p)]
> 
> I don't think you want ptrdiff_t there.  It isn't guaranteed to
> be big enough.

It is also a signed type.

> size_t should do, though.

This is an unsigned type, so the wrap around behavior is defined.
But do you really want to map a small negative index into a large 
positive one?

You probably have to use intptr_t and uintptr_t.

On the other hand if sizeof(size_t) == sizeof(type_of(tree for i))
is an implicit cast needed?

-- 
Derek M. Jones                              tel: +44 (0) 1252 520 667
Knowledge Software Ltd                      mailto:derek@knosof.co.uk
Applications Standards Conformance Testing    http://www.knosof.co.uk

  reply	other threads:[~2007-05-26  3:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-25 21:23 pointer arithmetics and casts Al Viro
2007-05-25 22:00 ` Al Viro
2007-05-26 15:45   ` Al Viro
2007-05-26  1:14 ` Morten Welinder
2007-05-26  3:32   ` Derek M Jones [this message]
2007-05-26  4:16     ` Al Viro
2007-05-26  3:43   ` Al Viro
2007-05-26  3:44 ` Neil Booth
2007-05-26  4:22   ` Al Viro
2007-05-26  4:37     ` Neil Booth

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=4657AA5F.1020705@knosof.co.uk \
    --to=derek@knosof.co.uk \
    --cc=linux-sparse@vger.kernel.org \
    --cc=mwelinder@gmail.com \
    --cc=viro@ftp.linux.org.uk \
    /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