delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/08/01/08:47:30

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Thu, 1 Aug 2013 08:47:14 -0400
Message-Id: <201308011247.r71ClEhM008182@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <op.w04oetou0e5s1z@-> (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@->
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 pointer can and does point to accessable memory for most C  
> compilers.

It's not the compiler that decides this, it's the operating system.
Many operating systems do not map the first page of memory, so a NULL
pointer may not point to accessible memory.

>  Typically, this is pointer or address to memory location zero, but
> it's not required to be.  It can be *any* value as long as no other
> C object has that same address.

"An integer constant expression with the value 0, or such an
 expression cast to type void *, is called a null pointer constant."

So, it's zero now.

> If NULL's type is a void pointer, it is (losslessly) converted to a char
> pointer when passed into a function for a char pointer argument.  I.e.,
> after the conversion, it functions as a char pointer in the function.

 "A string is a contiguous sequence of characters terminated by and
  including the first null character."

So there's a difference between "char pointer" and "pointer to a
string".  atoi() takes a pointer to a string.  Not all char pointers
are pointers to strings.

"If a null pointer constant is converted to a pointer type, the
 resulting pointer, called a null pointer, is guaranteed to compare
 unequal to a pointer to any object or function."

Since a pointer to any valid string cannot be equal to the null
pointer, a null pointer cannot point to a string.

- Raw text -


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