This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC headers and DJGPP port (OT)
- To: torvalds at transmeta dot com, gcc at gcc dot gnu dot org
- Subject: Re: GCC headers and DJGPP port (OT)
- From: Oleg Zabluda <zabluda at mindspring dot com>
- Date: Sun, 23 Jul 2000 07:21:13 -0400
- References: <Pine.LNX.4.10.10007222131230.1315-100000@penguin.transmeta.com>
- Reply-To: zabluda at mindspring dot com
On Thu, 28 Aug 2036, Linus Torvalds wrote:
>
> Off-topic: why is it exactly that C++ doesn't like the "((void *)0)"
> thing, which as far as I can tell has all the same advantages? Was it
> purely a "stupid standard" issue, or is there some actual real deeper
> reason for it?
>
> That was one of my pet peeves about C++: I always considered the
> historical "#define NULL 0" to be complete braindamage due to lack of
> even the simplest kind of type-checking (and matching to a pointer type
> is just one small portion of that type-checking - getting sane and
> appropriate warnings is quite important).
For the purpose of this discussion, it's enough to know that a "null pointer
constant" can be used to initialize or assign to a pointer, despite the fact
that their types do not match.
In both C and C++ ((int)0) was always a "null pointer constant". C additionally
allowed ((void*)0) to be a "null pointer constant". It was more acceptable in C
then in C++ because of the weaker typesystem. In C++ there is no implicit
conversion from void* to pointers-to-object, say int*.
Still, it's not a showcase of elegance. For example, in ANSI C there is
no conversion, implicit or otherwise, from void* to pointer-to-function.
In C++ inelegance would be even worse, because there are two more incompatible
pointer types: pointer-to-member-variable and pointer-to-member-function.
Oleg.