Path: utzoo!mnetor!uunet!husc6!rutgers!columbia!garfield.columbia.edu!eppstein
From: eppstein@garfield.columbia.edu (David Eppstein)
Newsgroups: comp.lang.c++
Subject: Bug in automatic type conversion?
Message-ID: <5192@columbia.edu>
Date: 14 Dec 87 19:34:37 GMT
Sender: nobody@columbia.edu
Organization: Columbia University CS Department
Lines: 40

I want to use automatic conversion of a certain class to strings, but it
seems to screw up other stuff around it.  This is in
	#ident	"@(#)cfront:CC	1.11"
and the error messages generated in the following program are:

	CC  test.c:
	"test.c", line 23: error: two initializers for baz() argument x
	"test.c", line 23: error: bad initializer type const_char_star
	   for x ( int  expected)
	2 errors

The program itself:

            ------------            ------------

typedef const char * const_char_star;

class string {
 public:
    const char * p;
    operator const_char_star() { return p; }
};

int strlen(const char *);

int baz(int = -1);

int foo()
{
    string bar;
    bar.p = "bar";
    return strlen(bar);
}

int baz(int x = -1)
{
    return x;
}
-- 
David Eppstein   eppstein@garfield.columbia.edu   Columbia U. Computer Science