delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/08/03/14:02:35

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 <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <op.w08sn91j0e5s1z@-> (dont_use_email@nohavenotit.com)
Subject: Re: _CRT0_FLAG_NULLOK
References: <21e77579-1a40-4442-8111-fc976fba78fc AT googlegroups DOT com>
<b5o37qFldl9U1 AT mid DOT dfncis DOT de>
<f24e8cd3-83ca-4386-a319-a9adb4d74c68 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> <op.w020sren0e5s1z@->
<87ehaeonbp DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <op.w04oetou0e5s1z@->
<201308011247 DOT r71ClEhM008182 AT delorie DOT com> <op.w08sn91j0e5s1z@->
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019