argv[] terminated by a NULL pointer?

Chris Torek torek at elf.ee.lbl.gov
Fri Jun 28 21:31:35 AEST 1991


In article <14603 at dog.ee.lbl.gov> I noted that
>>Under Version 6 Unix, argv[argc] is (char *)-1.  This violates the
>>following wording from X3.159-1989 (`ANSI C'):
>>    argv[argc] shall be a null pointer.  (2.1.1.2, p. 7)

In article <1991Jun28.052339.14611 at ringer.cs.utsa.edu>
djimenez at ringer.cs.utsa.edu (Daniel Jimenez) writes:
>Who said the null pointer couldn't be -1?

Perhaps I was overly terse.  I said `Version 6 Unix'; this implies a
whole range of things, for instance, that sizeof(int)==2, that the type
`long' existed only if you installed the `Phototypesetter V6' C
compiler, and so forth.  One of the implications is that the
implementation's nil-pointer-to-char is 16 zero bits.

>On a system where the null pointer is represented by all bits one,
>the following statement:
>((char *)0) == ((char *)-1) 
>would be true, since 0 in a pointer context is defined to be
>the null pointer, and -1 is also the null pointer.
>They would have the same bit pattern.

Correct, and good to know, but irrelevant to my point.  Once more,
that is:

	argv[argc] will be NULL if you have an ANSI conformant
	compiler.  If not, there is at most a `good chance' that
	it will exist and be NULL.

(Brownie points [Elven points?] to those who caught on to the `no and
yes' bit :-) .  If you look closely, you will find this in many of my
answers: qualifiers and limitations.  Strong, terse Anglo-Saxon verbs
are great, but sentences like `GCC kicks butt!' tend not to match well
to technical situations, and one winds up with polysyllabic provisional
Latinate words and passive voice: `GCC performs moderately well in
terms of generated code, and has the required support to use special
machine instructions needed to implement certain kernel functions.' But
this is heading towards misc.writing territory.  More appropriate here
is Gildor's reply. Frodo: `Go not to the Elves for counsel, for they
will say both no and yes'. Gildor: `Elves seldom give unguarded advice,
for advice is a dangerous gift, even from the wise to the wise.  You
have not told me all concerning yourself, and how then shall I choose
better than you?'  [And yes, I have elided some of the exchange.  That,
too, was intentional.])
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list