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