home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!yale.edu!ira.uka.de!slsvaat!josef!kanze
- From: kanze@us-es.sel.de (James Kanze)
- Newsgroups: comp.lang.c++
- Subject: NULL in C++ (was: Is this a compiler bug?)
- Message-ID: <KANZE.92Dec17201857@slsvdnt.us-es.sel.de>
- Date: 18 Dec 92 04:18:57 GMT
- References: <1992Dec8.183122.1@vax1.bham.ac.uk> <KANZE.92Dec11165414@slsvdnt.us-es.sel.de>
- <1992Dec11.193023.27787@news2.cis.umn.edu>
- <1992Dec14.212823.20514@microsoft.com>
- Sender: news@us-es.sel.de
- Organization: SEL
- Lines: 41
- In-Reply-To: jimad@microsoft.com's message of 14 Dec 92 21:28:23 GMT
-
- In article <1992Dec14.212823.20514@microsoft.com> jimad@microsoft.com
- (Jim Adcock) writes:
-
- [The thread that started this discussion deleted...]
- |> I think the confusion lies in assuming that ((void*)0) could be an
- |> acceptable implementation of NULL in C++. ((void*)0) is acceptable
- |> in C. It is not acceptable in C++. The rules of pointer type compatibility
- |> have changed, and are more restrictive in C++. Thus ((void*)0) no longer
- |> flies. This is a source of frequent trouble for C++ programmers trying to
- |> use old C .h files.
-
- This brings up another point.
-
- The C++ committee have aready changed wchar_t into a true type, rather
- than the typedef it was in C. Why couldn't NULL become a true
- reserved word in C++? Then we wouldn't have to worry about whether it
- was defined in a compatible way.
-
- Logically, this should lead to the deprication of assigning 0 to a
- pointer, or comparing a pointer to 0. The NULL pointer would then be
- represented as NULL, and not 0, and would unambiguously be a pointer.
-
- And of course, this would solve the ambiguity problem with overloaded
- functions:
-
- extern void f( int ) ;
- extern void f( void* ) ;
-
- f( 0 ) ; // Currently ambiguous, should call f( int )
- f( NULL ) ; // Currently ambiguous, should call f( void* )
-
- Somebody will no doubt prove me wrong, but I can't think of a single
- program that this would break (supposing the depricated implicit
- conversion). And the depricated conversion wouldn't hinder the above
- from working, since an exact match would be preferred over a
- conversion.
- --
- James Kanze email: kanze@us-es.sel.de
- GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
- Conseils en informatique industrielle --
- -- Beratung in industrieller Datenverarbeitung
-