From -5076173971530212351
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,f1dec9ce20a9c98f
X-Google-Attributes: gidf78e5,public
From: James.Kanze@dresdner-bank.com
Subject: Re: null pointers (was: Why's of C++ -- Part 1)
Date: 1999/08/24
Message-ID: <7puhhs$5ng$1@nnrp1.deja.com>#1/1
X-Deja-AN: 516719508
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7opqvm$vpa$1@news.hal-pc.org> <37B7C714.44E4EFB4@lucent.com> <7pcoem$105@abyss.West.Sun.COM> <7pdh80$qaf$1@engnews1.eng.sun.com> <7phdj7$4oj@abyss.West.Sun.COM> <2yG4gOAhsRv3EwJN@robinton.demon.co.uk> <37C16C7E.3C05BBA2@lucent.com>
X-Original-Date: Tue, 24 Aug 1999 16:34:04 GMT
X-Http-User-Agent: Mozilla/4.06 [de] (WinNT; I)
X-Complaints-To: news@news.unimelb.edu.au
X-Http-Proxy: 1.0 x24.deja.com:80 (Squid/1.1.22) for client 193.194.7.84
X-Trace: izvestia.its.unimelb.edu.au 935525839 29074 128.250.29.17 (24 Aug 1999 20:17:19 GMT)
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Tue Aug 24 16:34:04 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8L9tuEDnX0m9pzZAQETzwF+NvYEJvPxvqEcu3Cm2smj54bso73p0Ut+ CwJxV/HGVyVJfwkIJ8AoTaIOAA8z9v+0 =NmLu
X-MyDeja-Info: XMYDJUIDkanze
NNTP-Posting-Date: 24 Aug 1999 20:17:19 GMT
Newsgroups: comp.std.c++

In article <37C16C7E.3C05BBA2@lucent.com>,
  Salters <salters@lucent.com> wrote:
>
> Francis Glassborow wrote:

> > A further problem has just occurred to me.  Given an overload set
> > including f(int) and f(char *) how do I pass the value of the null
> > pointer constant to the second one?

> > f(0) resolves in a call to f(int)
> > f((void *)0) falls foul of there being no conversion
> > f((char *)0) may seem correct but it is not the null pointer
constant
> > and can be coded differently (and, I believe, actually is on some
> > debugging implementations).

> > It seems to me that C++ provides no standard conforming mechanism to
> > pass a null pointer constant to f(char *) in the presence of any
version
> > of f that can take an integer type argument.

> > I know it usually works in practice, but that is not the point.  If
I am
> > right, there is a defect in the Standard.

> Brute force - f( (char *)( (void *)0 ) )?

Not necessary.  f( (char*)0 ) works perfectly well (guaranteed by the
standard).  0 is a null pointer constant, and converting it to a pointer
must result in a null pointer.

> This must be a pointer to a char, initialized by a null pointer.
> Parsing:
> char * (              )	// create temporary of type char *
>          (void *) 0 )   // with this null pointer.
>
> The problem I fear is the "value of the null pointer constant".
> I'm not sure if the standard actually defines such a thing, the
> only requirement on null pointers being that they compare equal.

Correct.  The "null pointer constant" is a syntactical construct.  There
is, for example, no requirement that the representation of a char* null
pointer be the same as that of an int* null pointer.

--
James Kanze                   mailto: James.Kanze@dresdner-bank.com
Conseils en informatique orient�e objet/
                  Beratung in objekt orientierter Datenverarbeitung
Ziegelh�ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ 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              ]



