From owner-freebsd-stable Tue Oct 16 4:25:45 2001 Delivered-To: freebsd-stable@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 7BA0337B40D for ; Tue, 16 Oct 2001 04:25:41 -0700 (PDT) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 16 Oct 2001 12:25:40 +0100 (BST) Date: Tue, 16 Oct 2001 12:25:38 +0100 From: David Malone To: Zero Sum Cc: cjclark@alum.mit.edu, "Crist J. Clark" , Heath Nielson , Warner Losh , David Marker , freebsd-stable@FreeBSD.ORG Subject: Re: setenv() cores with NULL value [was Re: Gdm proplem on 4.4] Message-ID: <20011016122538.A12171@walton.maths.tcd.ie> References: <200110160353.f9G3rO728525@harmony.village.org> <20011016013834.E293@blossom.cjclark.org> <200110161002.f9GA2CA08544@shalimar.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200110161002.f9GA2CA08544@shalimar.net.au>; from count@shalimar.net.au on Tue, Oct 16, 2001 at 08:02:11PM +1000 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Oct 16, 2001 at 08:02:11PM +1000, Zero Sum wrote: > On Tuesday 16 October 2001 18:38, Crist J. Clark wrote: > > > > > > > setenv("TEST1", "", 1); > > > setenv("TEST2", NULL, 1); > > > > A huge difference. In the first case, the second argument is a > > pointer aimed at a string which contains the bytes, '\0'. In the > > second case, we have a null pointer. Null pointers point at nothing. > > I had that out with a compiler manufacturer long, long ago. At that > time it was a requirement for a 'correct' C compiler to regard a null > pointer and a pointer to a null string as sematically equivalent. Can you point to any document that refers to this? Maybe the compiler manufacturer was having you on. The C99 standard doesn't seem to mention "null string" as a term anywhere (though it's a common usage for people studying grammers) and "empty string" only crops up in relation to the nan function. Scanning through and looking for null by itself doesn't mention anything like this either. Infact, C99 says: If an argment to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to noon-modifiable storage when the corresponding parameter is not const-qualified), ..., the behaviour is undefined. which seems to suggest that unless NULL is specifically mentioned as beging acceptable then the compiler can do more-or-less as it pleases. AFAIK setenv isn't part of any standard which is likely to say that NULL is acceptable. David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message