www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/15/12:30:45

Date: Mon, 15 Jan 1996 19:08:05 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Erik Max Francis <max AT alcyone DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: Null pointers (was: (none))

On Sun, 14 Jan 1996, Erik Max Francis wrote:

> Eli Zaretskii wrote:
> 
> > Yes, it *is* better.  ANSI C says that the null pointer (for any type) is
> > a zero cast to a pointer to that type, but it doesn't guarantee that the
> > bit pattern for the null pointer is all-zero (so that !null_ptr is
> > true).  So you could write `if (my_pointer == 0)' (because the compiler
> > automatically will cast 0 to the pointer type), but `if (!my_pointer)'
> > may not work on some odd architectures.
> 
> Are you sure this is the case?  I was under the impression that (!p) was exactly
> as equivalent as (p == 0) in the context where p is a pointer.

You were right, I was wrong: it *is* the same.  It's just a matter of 
style, not standards.  Sorry to cause confusion.

- Raw text -


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