All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Roman Kagan <rkagan@virtuozzo.com>,
	"Denis V. Lunev" <den@openvz.org>,
	Andrey Smetanin <asmetanin@virtuozzo.com>,
	Linux-Sparse <linux-sparse@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH] Do not drop 'nocast' modifier when taking the address.
Date: Wed, 3 Feb 2016 10:15:56 +0100	[thread overview]
Message-ID: <20160203091555.GA3563@macbook.lan> (raw)
In-Reply-To: <CANeU7Qmch59PjG6FTk9kYoQ0Lg97pvP_SM+Nvccn+JPBW1Vunw@mail.gmail.com>

On Wed, Feb 03, 2016 at 12:09:16PM +0800, Christopher Li wrote:
> On Wed, Feb 3, 2016 at 11:43 AM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> pped.
> >
> > The nocast mod is dropped and lost in the function create_pointer().
> > In the example above, "cputime_t *" has type :
> >         unsigned long [nocast] [usertype] *
> > while &utime is just:
> >         unsigned long *
> 
> That is my point. Why does "&utime" get drop but "cputime_t *" does not?
> They both are pointer of a base type. They both create pointers.

Well with "cputime_t *" you got the pointer directly, by its own declaration;
with "&utime" you really _create_ one with the "&"/"addressof" operator.

The function "create_pointer()" is only called when evaluating an expression
using the addressof operator or when when an array of a function is degenerated
into a pointer.

> It seems to me the bug is sparse not treating this two case consistently.
> 
> > So, for sparse and its extended notion of type, the type we get when
> > taking the address of a [variable of some] type X is not the same as
> > directly using a pointer to the type X.
> 
> In C language type system,  these two should be the same type. It is a
> bug in sparse if they are not. I would rather get that bug fixed.

They _have_ the same type if we limit ourselves to the pure C type system,
but they differ once we look also at the sparse & gcc extension to the
type system, like the nocast attribute here.
 
Now, whether they should be the same or not is a question of defining the
semantic of the addressof operator on sparse's type extension.

> > Which is very fine, just that MOD_NOCAST is dropped while the example
> > shows that it should not.
> 
> I think that is a separate issue weather MOD_NOCAST should be inherent
> from pointer base type.

I'm not sure to understand you here.

> Same with MOD_STORAGE.
> 
> Chris

Luc

  reply	other threads:[~2016-02-03  9:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18 13:39 [kvm:queue 27/38] arch/x86/kvm/hyperv.c:186:41: sparse: incorrect type in argument 2 (different modifiers) kbuild test robot
2015-09-18 13:51 ` Denis V. Lunev
2015-09-18 13:55   ` Paolo Bonzini
2015-09-18 13:57     ` Denis V. Lunev
2015-09-18 14:40     ` Roman Kagan
2015-09-18 14:41       ` Paolo Bonzini
2015-09-18 15:06         ` [kbuild-all] " Fengguang Wu
2016-01-05 13:51           ` Luc Van Oostenryck
2016-01-05 16:25             ` [PATCH] Do not drop 'nocast' modifier when taking the address Luc Van Oostenryck
2016-02-02 20:25               ` Christopher Li
2016-02-03  3:43                 ` Luc Van Oostenryck
2016-02-03  4:09                   ` Christopher Li
2016-02-03  9:15                     ` Luc Van Oostenryck [this message]
2016-02-22 18:41                       ` Christopher Li

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=20160203091555.GA3563@macbook.lan \
    --to=luc.vanoostenryck@gmail.com \
    --cc=asmetanin@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkagan@virtuozzo.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.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.