[Top][All Lists]

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

Re: definition of NULL

From: Bruno Haible
Subject: Re: definition of NULL
Date: Tue, 11 Aug 2009 23:16:19 +0200
User-agent: KMail/1.9.9

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
         sizeof unary-expression
         sizeof ( type-name )
         ( 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.


reply via email to

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