Eric Blake wrote:
> I argue that NetBSD's definition of NULL is thus buggy

It appears to be compliant with ISO C99. This standard requires

6.5.3 and Annex A.2.1
Syntax
      unary-expression:
         ...
         sizeof unary-expression
         sizeof ( type-name )
      cast-expression:
         unary-expression
         ( type-name ) cast-expression

So, when you apply 'sizeof' to an expression, it must be a unary-expression.
But '(void*)0' is a cast-expression, not a unary-expression.

7.17.(3) "NULL which expands to an implementation-defined null pointer constant"

This does not require that the expansion is a unary-expression.


Regarding POSIX, with XSH 2.1.2.(1), you are probably right.

> we should add gnulib check and config.h workaround for it.

The definition of NULL is a particularly thorny area, because so many headers
use it and so many headers define it. I don't think it's worth the trouble -
it's easier to accept the fact that it's more reliable to parenthesize the
argument of sizeof when that argument is a macro invocation.

Bruno


Reply via email to