Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!swrinde!ringer!djimenez From: djimenez@ringer.cs.utsa.edu (Daniel Jimenez) Newsgroups: comp.lang.c Subject: Re: argv[] terminated by a NULL pointer? Message-ID: <1991Jun28.052339.14611@ringer.cs.utsa.edu> Date: 28 Jun 91 05:23:39 GMT References: <12187@hub.ucsb.edu> <14603@dog.ee.lbl.gov> Organization: University of Texas at San Antonio, San Antonio, Texas Lines: 25 In article <14603@dog.ee.lbl.gov> torek@elf.ee.lbl.gov (Chris Torek) writes: >In article <12187@hub.ucsb.edu> angst@cs.ucsb.edu >(Hopelessly in love w/Donna Reed) writes: >>I'm porting some code that assumes that the argv[] array is terminated >>by a NULL pointer.... am I right in my belief that argv[] is not >>*guaranteed* to be terminated by a NULL pointer? > >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) > Who said the null pointer couldn't be -1? 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. -- * Daniel A. Jimenez * Please excuse my longwindedness. * djimenez@ringer.cs.utsa.edu * This Sun terminal makes everything * dajim@lonestar.utsa.edu * I write seem important. * Opinions expressed here are mine only, and not those of UTSA.