From 8684996314821777024
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,b64079e03addd8e4
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,696412d44c359f7f,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-05 11:08:52 PST
Newsgroups: comp.lang.c++,comp.std.c++
Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!swrinde!ihnp4.ucsd.edu!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: void\* vs const void\*
Message-ID: <9500521.19214@mulga.cs.mu.OZ.AU>
Followup-To: comp.std.c++
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <3ec5n4$2cib@ns2.CC.Lehigh.EDU>
Date: Thu, 5 Jan 1995 10:33:25 GMT
Lines: 49
Xref: nntp.gmd.de comp.lang.c++:85164 comp.std.c++:10968

pjm3@ns2.CC.Lehigh.EDU (PAUL JASON MARTINO) writes:

>I am getting some strange results running the following code on Borland 4.5.
>
>void f( void * );
>void f( const void * );
>
>void main()

main() should return an `int'.

>    {
>    char *c;
>
>    f( c );          // does not issue an error
>    f( (char *) 0 ); // error: ambiguous
>    }
>
>I can find nothing in the standard doc that should make the f(c) call be
>non-ambiguous. Borland 3.1 flags f(c) as an error. Our product PC-Lint for
>C/C++ flags both of them as an error. I was curious is anyone knows who is
>correct.

Neither PC-Lint nor Borland 3.1 is correct, IMHO - both statements
should be unambiguous, and should invoked `f(void *)'.
But Borland's behaviour seems particularly strange, since there
shouldn't be any difference between `c' and `(char *)0' in this case.

I base my conclusion on the Sept working draft.
The conversion sequences involved in this case are

	S1: (char *) -> (void *)

and
	S2: (char *) -> (void *) -> (const void *)

Now 13.2.3.2/3 states:

	Standard conversion sequence S1 is a better conversion sequence
	than standard conversion sequence S2 if
		- S1 is a proper subsequence of S2, or ...

Hence S1 is a better conversion sequence than S2, and so there is
no ambiguity - the code should invoke `f(void *)'.

P.S. Followups redirected to comp.std.c++.

-- 
Fergus Henderson - fjh@munta.cs.mu.oz.au


