standards/50889: NULL defined as 0 instead of (void *)0

Erik Trulsson ertr1013 at student.uu.se
Wed Apr 16 05:57:20 PDT 2003


On Wed, Apr 16, 2003 at 05:49:55AM -0700, Jens Schweikhardt wrote:
> Synopsis: NULL defined as 0 instead of (void *)0
> 
> State-Changed-From-To: open->analyzed
> State-Changed-By: schweikh
> State-Changed-When: Wed Apr 16 05:38:52 PDT 2003
> State-Changed-Why: 
> The bug is in your code. Because ISO 9899 explicitly allows NULL to be
> defined as 0 (C99 6.3.2.3), any code must take this possibility into
> account. If expansion to 0 leads to different semantics than expansion
> to (void*)0 then the code must use a cast.

Correct.

> 
> I agree, though, that it may be desirable to
> #define NULL ((void*)0)

Unless you want to use the same definition for both C and C++.
In C++ the only valid way of defining NULL is

#define NULL 0

because in C++ there is no automatic conversion between "pointer to
void" and other pointer types as there is in C.

> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=50889
> _______________________________________________
> freebsd-standards at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-standards
> To unsubscribe, send any mail to "freebsd-standards-unsubscribe at freebsd.org"

-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at student.uu.se


More information about the freebsd-standards mailing list