From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2554 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: NULL Date: Sat, 12 Jan 2013 01:42:54 -0500 Message-ID: <20130112064254.GF20323@brightrain.aerifal.cx> References: <50ED4E45.6050801@barfooze.de> <1357970162.32505.3@driftwood> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1357972990 1942 80.91.229.3 (12 Jan 2013 06:43:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Jan 2013 06:43:10 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2555-gllmg-musl=m.gmane.org@lists.openwall.com Sat Jan 12 07:43:28 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TtuoR-0000E7-H2 for gllmg-musl@plane.gmane.org; Sat, 12 Jan 2013 07:43:27 +0100 Original-Received: (qmail 20233 invoked by uid 550); 12 Jan 2013 06:43:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20207 invoked from network); 12 Jan 2013 06:43:07 -0000 Content-Disposition: inline In-Reply-To: <1357970162.32505.3@driftwood> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2554 Archived-At: On Fri, Jan 11, 2013 at 11:56:02PM -0600, Rob Landley wrote: > On 01/09/2013 05:02:29 AM, John Spencer wrote: > >glibc defines NULL as __null: a magic variable supplied by GCC and > >compatibles which always has pointer context. > > > >musl defines NULL to 0 in C++. > >this is correct per the standard, but breaks a lot of software on > >64bit archs, > >because it promotes to int. > > The C99 standard section 7.17 defines the NULL macro as: > > expands to an implementation-defined null pointer constant > > Which means it has pointer type. So either we can typecast it to Nope, C is weirder than you think. A "null pointer constant" is defined as an integer constant expression with value zero, or such an expression cast to void *. So it need not have pointer type. > void *, or we can rely on the LP64 standard (Linux, FreeBSD, and > macosX all support) which says that long and pointer are always the > same size on both 32 bit and 64 bit, so trivial fix would be #define > NULL to (0L) Yes, using 0L on both C and C++ is the solution I'm leaning towards.. Rich