c++/4337: [2003-01-01]c++ ignores cast operator

Giovanni Bajo giovannibajo@libero.it
Wed May 14 00:47:00 GMT 2003


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



More information about the Gcc-bugs mailing list