[comp.std.c] null pointers joke?

jeenglis@nunki.usc.edu (Joe English) (10/28/89)

bdm659@csc.anu.oz writes:

>    Section 3.2.2.3 (on the result of casting 0 to a pointer type):
>
>          "Such a pointer, called a null pointer, is guaranteed not to
>           point to any object or function."
>
>    Section 3.3.9 (on pointer equality):
>
>          "If two pointers to object or incomplete types compare equal,
>           they point to the same object."
>
>From these two rules, it logically follows that  (int*)0 != (int*)0 .

Not really; 3.3.9 says (loosely translated)

[(A and B point to an object) and (A == B)] ==> [it is the same object].  
  (1)                             (2)           (3)

If (1) is false it does not follow that (2) is false.
 

--Joe English

  jeenglis@nunki.usc.edu

bdm659@csc.anu.oz (10/28/89)

In article <8952@goofy.megatest.UUCP>, djones@megatest.UUCP (Dave Jones) writes:
>
> 1. The sections concerning pointers are poorly written.
> It will not surprise me at all if a literal reading of them leaves some
> expected behavior unspecified.
>
> 2. It doesn't matter.

    Section 3.2.2.3 (on the result of casting 0 to a pointer type):

          "Such a pointer, called a null pointer, is guaranteed not to
           point to any object or function."

    Section 3.3.9 (on pointer equality):

          "If two pointers to object or incomplete types compare equal,
           they point to the same object."

From these two rules, it logically follows that  (int*)0 != (int*)0 .

Choose between  :-)  and  :-(  yourself.

==========================
Brendan McKay.  bdm@anucsd.oz  or  bdm@anucsd.oz.au  (via uunet.uu.net)
                The address in the header may be scrambled.

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/28/89)

In article <872.254895b5@csc.anu.oz> bdm659@csc.anu.oz writes:
-    Section 3.2.2.3 (on the result of casting 0 to a pointer type):
-          "Such a pointer, called a null pointer, is guaranteed not to
-           point to any object or function."
-    Section 3.3.9 (on pointer equality):
-          "If two pointers to object or incomplete types compare equal,
-           they point to the same object."
-From these two rules, it logically follows that  (int*)0 != (int*)0 .

Of course this is utter nonsense.  The conclusion does not follow
from those rules.  (int*)0 is not a pointer to an object or an
incomplete type.

datanguay@watmath.waterloo.edu (David Adrien Tanguay) (10/28/89)

In article <872.254895b5@csc.anu.oz> bdm659@csc.anu.oz writes:
:    Section 3.2.2.3 (on the result of casting 0 to a pointer type):
:
:          "Such a pointer, called a null pointer, is guaranteed not to
:           point to any object or function."
:
:    Section 3.3.9 (on pointer equality):
:
:          "If two pointers to object or incomplete types compare equal,
:           they point to the same object."
:
:From these two rules, it logically follows that  (int*)0 != (int*)0 .

(int *) 0 is not a pointer to an object, so section 3.3.9 doesn't come
into play.

:Brendan McKay.  bdm@anucsd.oz  or  bdm@anucsd.oz.au  (via uunet.uu.net)

David Tanguay

bdm659@csc.anu.oz (10/28/89)

In article <11432@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> In article <872.254895b5@csc.anu.oz> bdm659@csc.anu.oz writes:
> -    Section 3.2.2.3 (on the result of casting 0 to a pointer type):
> -          "Such a pointer, called a null pointer, is guaranteed not to
> -           point to any object or function."
> -    Section 3.3.9 (on pointer equality):
> -          "If two pointers to object or incomplete types compare equal,
> -           they point to the same object."
> -From these two rules, it logically follows that  (int*)0 != (int*)0 .
>
> Of course this is utter nonsense.  The conclusion does not follow
> from those rules.  (int*)0 is not a pointer to an object or an
> incomplete type.

I didn't say it was.  In fact, I agree it isn't either of those things.
The trouble is that the sentence only requires "pointers to object or
incomplete types", which can only be parsed as "pointers to object types or
pointers to incomplete types".  If it said "objects" instead of "object"
you would have a strong case, but it doesn't, so you don't.

In any case, I could use (void*)0 instead of (int*)0 to avoid this semantic
point, as (void*)0 is certainly a "pointer to incomplete type".

Thus, you are wrong in claiming that the two sentences (AS QUOTED - see my
query at the end) don't imply my conclusion.

However, it turns out that I'M WRONG TOO, for another reason.
Merv Rubinstein informs me that in the draft of Dec. 7 1988 it says

        "If two pointers to object or incomplete
         types are both null, they compare equal."

This proves
 (a) that the phrase "pointers to object or incomplete types" is NOT intended
     to exclude null pointers.  [So much for the "utter nonsense", Doug.]
     Just as well, too, because it would be a pity if we had to give up
     applying 3.2.2.3 and 3.3.4 to them.
 (b) that the difficulty I found in my earlier draft has been already found
     and taken care of.
 (c) that I should wait for my copy of the latest draft to arrive before
     posting articles like that.  (I have a few other "jokes?" up my
     sleeve, but I'll wait until I can argue them with complete knowledge
     of the facts.)

Query:
  Has the sentence from 3.3.9 in the ">" section above been modified to avoid
the contradiction?  (I quoted it from a posting of Bill Wells.  My copy of
the draft is so old that it doesn't have it at all.)
That isn't very important with the new sentence close by, of course, but any
mathematician knows that practically anything can be proved or disproved if
one contradiction is assumed.

Brendan McKay. =============================================================
bdm@anucsd.oz or bdm@anucsd.oz.au    (via uunet.uu.net)

bdm659@csc.anu.oz (10/28/89)

> Merv Rubinstein informs me that in the draft of Dec. 7 1988 it says

That should be "Marv".  Sorry Marv.

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/30/89)

In article <876.2549cbb7@csc.anu.oz>, bdm659@csc.anu.oz writes:
|  However, it turns out that I'M WRONG TOO, for another reason.
|  Merv Rubinstein informs me that in the draft of Dec. 7 1988 it says
|  
|          "If two pointers to object or incomplete
|           types are both null, they compare equal."

  Another case of "no substantive changes," right?
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/31/89)

In article <1518@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes:
>|          "If two pointers to object or incomplete
>|           types are both null, they compare equal."
>  Another case of "no substantive changes," right?

Right.  Or do you want to argue that X3J11 ever intended that
	(int*)0 != (int*)0