From -3355614355062575526
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,f1dec9ce20a9c98f
X-Google-Attributes: gidf78e5,public
From: Pete Becker <petebecker@acm.org>
Subject: Re: null pointers (was: Why's of C++ -- Part 1)
Date: 1999/08/19
Message-ID: <37BC4AC8.EDB45FDF@acm.org>#1/1
X-Deja-AN: 514829330
X-NNTP-Posting-Host: 24.128.201.83
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7opqvm$vpa$1@news.hal-pc.org><7p0mu0$36f$1@mulga.cs.mu.OZ.AU> <FGEw80.FB0@research.att.com><37B48FBA.2DE77379@tribble.com> <FGGtEt.8zG@research.att.com> <7pbjul$r9f$1@nnrp1.deja.com> <7pc9h4$1kds$1@news.hal-pc.org> <37BB6D8B.ADD24984@acm.org> <7pgr93$1m2b$1@news.hal-pc.org>
X-Accept-Language: en
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@mediaone.net
X-Trace: wbnws01.ne.mediaone.net 935086838 24.128.201.83 (Thu, 19 Aug 1999 14:20:38 EDT)
Organization: Road Runner
Mime-Version: 1.0
NNTP-Posting-Date: Thu, 19 Aug 1999 14:20:38 EDT
Newsgroups: comp.std.c++
Originator: clamage@taumet


Greg Brewer wrote:
> 
> Pete Becker <petebecker@acm.org> wrote in message
> news:37BB6D8B.ADD24984@acm.org...
> > > I agree with you on you last point but how would you feel about a
> proposal
> > > that would make calling
> > >   void f(char *);
> > >   void f(int);
> > > with
> > >    f(NULL);
> > > and
> > >    f(0);
> > > no longer abiguous?
> > They are not currently ambiguous. Both call f(int).
> 
> Not according to Borland C++ 5.01.  Which is preferable to in the case of
> f(NULL).
> 

If you want to do compiler polls, Borland C++ 5.3 doesn't complain about
ambiguity. Neither does VC++ 5.0 nor VC++ 6.0, nor gcc (egcs-1.1.2), nor
the Edison Design Group compiler. gcc resolves f(NULL) to f(void*)
because of its definition of NULL as __null. All the others resolve
f(NULL) to f(int), and all five compilers resolve f(0) to f(int).

But more to the point is that the language definition says that these
calls are not ambiguous. 0 as a null pointer constant can be converted
to a null pointer in order to call f(char*), but as an int it needs no
conversion in order to call f(int), so f(int) is the correct choice.

-- 
Pete Becker
Dinkumware, Ltd.
http://www.dinkumware.com


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




