Re: Non-null pointers in C/C++?
  Home FAQ Contact Sign in
comp.lang.c.moderated only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Non-null pointers in C/C++?         

Group: comp.lang.c.moderated · Group Profile
Author: angel_tsankov
Date: May 22, 2008 14:51

On 15 Май, 19:00, Hans-Bernhard Bröker wrote:
> Note: I will ignore you mentioned C++ at all.
>
> angel_tsankov wrote:
>> It's been some time since I started wondering why the C/C++ languages
>> do not have a non-null pointer (something like a copyable C++
>> reference)?
>
> Because it wouldn't work.  Just because a pointer can't be NULL doesn't
> mean it's safer to use.  It could still be invalid in any number of
> other ways.
>
>> -provide compilers with further semantic information, thus enabling
>> them to perform more optimizations;
>
> There's no optimization you could do with a non-null pointer that you
> would be forbidden to do with a NULL pointer --- optimizations are
> already completely free to pick among various different kinds of
> undefined behaviour.  C code never has to check a pointer for NULL
> before using it.

Sure, there would be optimizations. For instance, you can safely skip
the null checks. The standard library could do this also, e.g. in
functinos where this matters (free for example).
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Re: iTunes non è una monnezza perchè non si può dire ma ad essere onesti...it.comp.macintosh ·