X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com From: "Stephen J. Turnbull" To: djgpp AT delorie DOT com Subject: Re: _CRT0_FLAG_NULLOK In-Reply-To: References: <21e77579-1a40-4442-8111-fc976fba78fc AT googlegroups DOT com> <3df2f50f-9543-47a7-8e40-a9be82ce5018 AT googlegroups DOT com> <87fvuvny2v DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <87ehaeonbp DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <87zjt1n2v6 DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> X-Mailer: VM undefined under 21.5 (beta32) "habanero" b0d40183ac79 XEmacs Lucid (x86_64-unknown-linux) Cancel-Lock: sha1:lGlqklcZaOOAgE7a35/2+brmy+o= Date: Sun, 04 Aug 2013 00:54:42 +0900 Message-ID: <8761vmn519.fsf@uwakimon.sk.tsukuba.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Rod Pemberton writes: > On Thu, 01 Aug 2013 06:04:45 -0400, Stephen J. Turnbull > wrote: > > > Rod Pemberton writes: > > > > > E.g., [C definition committees] could've specified a NULL pointer > > > always points to an emtpy string of just a null character. Such a > > > specification is unlikely to break C, since a NULL pointer just > > > needs to have a unique address. This would've allowed a NULL > > > pointer to safely function as an empty character string too. > > > > Which is an arbitrary decision, > > True. But, how is that any different than specifying NULL in the > first place? All I'm saying is, look at char *a = NULL; char *b = "This is a pen.\n"; char *c = b + strlen(b); char *d = malloc(255); char *e = ""; and tell me "which of these things is not like the others?" > No, it wouldn't likely be a pointer to arbitrary instance of some > type other than a char. That's the only type that would serve > some purpose due to the way strings are implemented in C. > Other types don't have this issue. Huh? Now you're speaking in non sequiturs. How often do you see idioms like: void footloose_and_fancy_free (double **dp) { free (*dp); *dp = NULL; } And I personally find it useful that on most OSes (*NULL) kills your program, no matter what type of pointer NULL has been coerced to. This has saved me from doing something stupid many times. > It would only add additional functionality to NULL for use as char > pointers. It doesn't add any functionality. See variable "e" above. It simply allows programmers to make mistakes with strings they couldn't make with other pointer types. If you want the functionality you talk about, it's easy enough to get it without forcing implementations to do something bizarre with NULL. Just poke a zero into memory somewhere and get a pointer to it. Give that pointer a name: char *empty_string = "";