[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
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
- Re: definition of NULL, Bruno Haible, 2009/08/11
- Re: definition of NULL, Eric Blake, 2009/08/11
- Re: definition of NULL, Eric Blake, 2009/08/11
- Re: definition of NULL,
Bruno Haible <=
- Re: definition of NULL, Eric Blake, 2009/08/12
- Re: definition of NULL, Ralf Wildenhues, 2009/08/13
- Re: definition of NULL, Eric Blake, 2009/08/13
- Re: definition of NULL, Ralf Wildenhues, 2009/08/13
- Re: definition of NULL, Bruno Haible, 2009/08/13
- Re: definition of NULL, Eric Blake, 2009/08/13
- Re: definition of NULL, Eric Blake, 2009/08/14
- git format-patch on .texi (was: definition of NULL), Eric Blake, 2009/08/13
- Re: git format-patch on .texi, Eric Blake, 2009/08/14
- Re: definition of NULL, Bruno Haible, 2009/08/14