This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc-2.95 bug report
- To: gcc-bugs at gcc dot gnu dot org
- Subject: gcc-2.95 bug report
- From: Adam McKee <amckee at home dot com>
- Date: Thu, 12 Aug 1999 20:17:53 -0600 (CST)
gcc version: 2.95
OS: Linux 2.2.11 on an Intel P-166
gcc configuration: I got the compiler binaries from
ftp://contrib.redhat.com
Attached is a very small program that reproduces the problem.
Bug Description:
Here's what I get when I compile the attached program:
% g++ -o test test.cpp
test.cpp: In function `int main()':
test.cpp:24: warning: choosing `Object::operator char *()' over
`Object::operator const char *() const'
test.cpp:24: warning: for conversion from `Object' to `const char *'
test.cpp:24: warning: because conversion sequence for the argument is
better
There is a user-defined conversion directly from (Object) to (const char*)
so I think the compiler should just quietly use it. I don't see why it
would regard the other conversion as better, since it will require a
conversion from (char*) to (const char*) afterward.
How can I disable this warning? In the meantime I'll go back to
egcs-1.1.2.
I hope this helps, though I suspect this may have already been
reported.
-- Adam
#define NULL 0
class Object
{
public:
operator char*()
{ return NULL; }
operator const char*() const
{ return NULL; }
};
void
foo(const char* s)
{}
int
main()
{
Object object;
// next line generates a silly warning
foo(object);
return 0;
}