From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Zabluda To: torvalds@transmeta.com, gcc@gcc.gnu.org Subject: Re: GCC headers and DJGPP port (OT) Date: Sun, 23 Jul 2000 06:19:00 -0000 Message-id: <00072308122900.12057@marianna> References: X-SW-Source: 2000-07/msg00715.html 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.