mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Cong WANG" <xiyou.wangcong@gmail.com>
To: davids@webmaster.com, linux-kernel@vger.kernel.org,
	"Jan Engelhardt" <jengelh@linux01.gwdg.de>
Subject: Re: Style Question
Date: Mon, 12 Mar 2007 21:52:02 +0800	[thread overview]
Message-ID: <2375c9f90703120652w59ca82a5k5e3f4d0ccaee80af@mail.gmail.com> (raw)
In-Reply-To: <MDEHLPKNGKAHNMBLJOLKOEBCCDAC.davids@webmaster.com>

2007/3/12, David Schwartz <davids@webmaster.com>:
>
> > NULL has the same bit pattern as the number zero. (I'm not saying the bit
> > pattern is all zeroes. And I am not even sure if NULL ought to
> > have the same
> > pattern as zero.) So C++ could use (void *)0, if it would let itself :p
>
> They don't have to have the same bit pattern. There's no logical reason a
> NULL pointer couldn't have all bits set and the number zero have all bits
> cleared.
>
> Casts are perrmited to change the bit pattern. For example '(float) 7' can
> result in a different bit pattern than '7' and similarly '(void *) 0' can
> result in a different bit pattern from '0'.
>
> As a trivial example, consider an LP64 system. NULL will have the bit
> pattern of 64 zero bits, while '0' will have the bit pattern of 32 zero
> bits.
>
> DS

I agree. C99 standard just says:

6.3.2.3 Pointers

"3  An integer constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer constant. If
a null pointer constant is converted to a pointer type, the resulting
pointer, called a null pointer, is guaranteed to compare unequal to a
pointer to any object or function."

  parent reply	other threads:[~2007-03-12 13:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 14:15 Cong WANG
2007-03-11 14:22 ` Bernd Petrovitsch
2007-03-11 20:35 ` Jan Engelhardt
2007-03-11 20:41   ` Daniel Hazelton
2007-03-11 22:01     ` Kyle Moffett
2007-03-11 23:16       ` Jan Engelhardt
2007-03-12  1:27         ` Kyle Moffett
2007-03-12  1:32           ` Jan Engelhardt
2007-03-12  1:43             ` Kyle Moffett
2007-03-12  5:37   ` Cong WANG
2007-03-12  5:40     ` Jan Engelhardt
2007-03-12  5:52       ` Nicholas Miell
2007-03-12  6:18       ` Randy.Dunlap
     [not found]       ` <MDEHLPKNGKAHNMBLJOLKOEBCCDAC.davids@webmaster.com>
2007-03-12 13:52         ` Cong WANG [this message]
     [not found] <fa.Da+t1e9MgP7HaKS+dOWXVD8aYNI@ifi.uio.no>
2007-03-11 15:47 ` Robert Hancock

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=2375c9f90703120652w59ca82a5k5e3f4d0ccaee80af@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=davids@webmaster.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®