Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!agate!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.lang.c Subject: Re: argv[] terminated by a NULL pointer? Message-ID: <14780@dog.ee.lbl.gov> Date: 28 Jun 91 11:31:35 GMT Article-I.D.: dog.14780 References: <12187@hub.ucsb.edu> <14603@dog.ee.lbl.gov> <1991Jun28.052339.14611@ringer.cs.utsa.edu> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 47 X-Local-Date: Fri, 28 Jun 91 04:31:35 PDT In article <14603@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@ringer.cs.utsa.edu> djimenez@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@ee.lbl.gov