Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Apr 2003 14:57:15 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Jens Schweikhardt <schweikh@FreeBSD.org>
Cc:        lamer@properfucked.net
Subject:   Re: standards/50889: NULL defined as 0 instead of (void *)0
Message-ID:  <20030416125715.GA12300@falcon.midgard.homeip.net>
In-Reply-To: <200304161249.h3GCntqZ071047@freefall.freebsd.org>
References:  <200304161249.h3GCntqZ071047@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-standards
> To unsubscribe, send any mail to "freebsd-standards-unsubscribe@freebsd.org"

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030416125715.GA12300>