[cfe-dev] Fixing selector types on the GNU runtime
me22
me22.ca at gmail.com
Tue Jan 20 18:49:20 PST 2009
On Tue, Jan 20, 2009 at 20:46, David Chisnall <csdavec at swansea.ac.uk> wrote:
>
> The question at hand is whether, according to the C++ spec, NULL, when
> passed to a variadic function, will always be a 0 pointer. I can't
> find a single reference to support this. If you have one, then it's a
> bug in g++ combined with the FreeBSD headers. If you don't, then it's
> a fault in LLVM's usage of NULL, which happens not to matter on some
> platforms.
>
The only description of NULL that I can find is 18.1/4:
"The macro NULL is an implementation-defined C++ null pointer constant
in this International Standard (4.10).[footnote: Possible definitions
include 0 and 0L, but not (void*)0.]"
A "null pointer constant" is, by 4.10, is an integral constant rvalue
expression that evaluates to zero.
Since variable argument don't trigger any implicit conversions, NULL
has no reason to become a pointer.
(Especially since, as you mentioned, the NULL macro is expanded in
translation phase 4, well before the syntactic and semantic analysis
and translation of phase 7.)
~ Scott
#define NULL (3/2-1)
P.S. If you're looking for a legal electronic copy, consider the 1997
public review version ( http://www.open-std.org/jtc1/sc22/open/n2356/
) and the april 2004 draft (
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1638.pdf ), a
combination of which should give a good picture of C++2003.
More information about the cfe-dev
mailing list