X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Sat, 3 Aug 2013 14:02:23 -0400 Message-Id: <201308031802.r73I2NAq010284@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: (dont_use_email@nohavenotit.com) Subject: Re: _CRT0_FLAG_NULLOK 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> <201308011247 DOT r71ClEhM008182 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 > A NULL is not required to be mapped to low memory. This is > irrelevant. NULL's actual value is not required to be zero, only > different. NULL's actual value is required to be zero, from the program's point of view. > (No joke. You can ask even the angry nutjobs on c.l.c and get that > correct answer. Please read the two posts which I provided links > to. They're by one of the authors of the ANSI C specifications.) Sure. The physical address of "0" in a virtual memory system is rarely itself zero, and some systems use segment/offset or tag/offset addressing too. > True. We were discussing how to make a NULL more useful by > preventing atoi() from failing when passed in. One method is for > NULL to be not just a "char pointer", but also be "a pointer to a > string" - an empty string. IMHO, making "passing NULL" crash your app is more useful, because then the debugger can tell you exactly where you went wrong. Even the MCU simulators I write for work have *NULL==crash for debugging. > Sorry, you've made a logic error here. The prior quote of yours > only requires the address used for the NULL to be unequal to any > valid object or function. You've implicitly defined your own term: > "valid string", s/string/array of char/ then arrays are certainly valid objects. IMHO if a pointer points to *anything* that "works", it's a bad choice for NULL.