bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: definition of NULL


From: Eric Blake
Subject: Re: definition of NULL
Date: Tue, 11 Aug 2009 20:15:48 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bruno Haible <bruno <at> clisp.org> writes:

> > +verify (sizeof NULL == sizeof (void *));
> 
> Citing <https://savannah.gnu.org/support/?106973>:
> 
>   on NetBSD 5.0 amd64, test-locale.c fails to build
>   because the call to verify says "sizeof NULL".   On NetBSD, NULL is "(void
>   *)0", and gcc fails to parse "sizeof (void*)0".  Changing this to "sizeof
>   (NULL)" makes the tests compile
> 
> Indeed, "sizeof (void*)0" parses as sizeof of the type 'void *', followed by a
> stray 0 token => parse error.

I argue that NetBSD's definition of NULL is thus buggy, and that we should add 
a gnulib check and config.h workaround for it.  POSIX requires:

"The macro shall expand to an integer constant expression with the value 0 cast 
to type void *."

which implies to me that I should be able to use NULL without having to add 
extra parenthesis myself.

-- 
Eric Blake







reply via email to

[Prev in Thread] Current Thread [Next in Thread]