From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21383 invoked by alias); 14 May 2003 00:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21368 invoked by uid 71); 14 May 2003 00:46:00 -0000 Date: Wed, 14 May 2003 00:46:00 -0000 Message-ID: <20030514004600.21367.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Giovanni Bajo" Subject: Re: c++/4337: [2003-01-01]c++ ignores cast operator Reply-To: "Giovanni Bajo" X-SW-Source: 2003-05/txt/msg01529.txt.bz2 List-Id: The following reply was made to PR c++/4337; it has been noted by GNATS. From: "Giovanni Bajo" To: "Bogdanov, Serge" , , , , Cc: Subject: Re: c++/4337: [2003-01-01]c++ ignores cast operator Date: Wed, 14 May 2003 02:36:09 +0200 Bogdanov, Serge 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