This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/4337: [2003-01-01]c++ ignores cast operator
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: "Bogdanov, Serge" <serge dot bogdanov at intel dot com>,<gcc-bugs at gcc dot gnu dot org>,<gcc-prs at gcc dot gnu dot org>,<nobody at gcc dot gnu dot org>,<gcc-gnats at gcc dot gnu dot org>
- Date: Wed, 14 May 2003 02:36:09 +0200
- Subject: Re: c++/4337: [2003-01-01]c++ ignores cast operator
- References: <A5974D8E5F98D511BB910002A50A66470AA633B1@hdsmsx103.hd.intel.com>
Bogdanov, Serge <serge.bogdanov@intel.com> wrote:
> The latest analysis by Giovanni solves one mystery, but there is
> another one in the same bug report: if the cast operator is removed,
> compiler produces warnings.
>
>>>> g++ -o a a.cpp
> a.cpp: In function `int main()':
> a.cpp:27: warning: choosing `A2::operator A1()' over `A1::A1(const A&)'
> a.cpp:27: warning: for conversion from `A2' to `A1'
> a.cpp:27: warning: because conversion sequence for the argument is
better
And what would the problem be? If you remove the cast operator, you end up
with "a2 = a1" which obviously selects the cast operator. The compiler is
just warning you about the possible ambiguity, but it's choosing the right
path.
Giovanni Bajo