This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]